diff --git a/changelog.txt b/changelog.txt index d36b2ef1..894bdd47 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,44 @@ +Version 4.9.11 (2020-07-13) + Fixed the `selection.setContent()` API not running parser filters #TINY-4002 + Fixed content in an iframe element parsing as DOM elements instead of text content #TINY-5943 + Fixed up and down keyboard navigation not working for inline `contenteditable="false"` elements #TINY-6226 +Version 4.9.10 (2020-04-23) + Fixed an issue where the editor selection could end up inside a short ended element (eg br) #TINY-3999 + Fixed a security issue related to CDATA sanitization during parsing #TINY-4669 + Fixed `media` embed content not processing safely in some cases #TINY-4857 +Version 4.9.9 (2020-03-25) + Fixed the table selection not functioning correctly in Microsoft Edge 44 or higher #TINY-3862 + Fixed the table resize handles not functioning correctly in Microsoft Edge 44 or higher #TINY-4160 + Fixed the `forced_root_block_attrs` setting not applying attributes to new blocks consistently #TINY-4564 + Fixed the editor failing to initialize if a script tag was used inside an SVG #TINY-4087 +Version 4.9.8 (2020-01-28) + Fixed the `mobile` theme failing to load due to a bundling issue #TINY-4613 + Fixed security issue related to parsing HTML comments and CDATA #TINY-4544 +Version 4.9.7 (2019-12-19) + Fixed the `visualchars` plugin converting HTML-like text to DOM elements in certain cases #TINY-4507 + Fixed an issue with the `paste` plugin not sanitizing content in some cases #TINY-4510 + Fixed HTML comments incorrectly being parsed in certain cases #TINY-4511 +Version 4.9.6 (2019-09-02) + Fixed image browse button sometimes displaying the browse window twice #TINY-3959 +Version 4.9.5 (2019-07-02) + Changed annotations navigation to work the same as inline boundaries #TINY-3396 + Fixed the print plugin printing from the wrong window in IE11 #TINY-3762 + Fixed an exception being thrown when a file or number input has focus during initialization. Patch contributed by t00 #GH-2194 + Fixed positioning of the styleselect menu in iOS while using the mobile theme #TINY-3505 + Fixed native context menu not showing with images in IE11 #TINY-3392 + Fixed selection incorrectly changing when programmatically setting selection on contenteditable false elements #TINY-3766 + Fixed image browse button not working on touch devices #TINY-3751 + Fixed so that nbsp entities aren't trimmed in white-space: pre-line elements #TINY-3642 + Fixed space key properly inserts a nbsp before/after block elements #TINY-3745 + Fixed infinite loop in the paste plugin when IE11 takes a long time to process paste events. Patch contributed by lRawd. #GH-4987 +Version 4.9.4 (2019-03-20) + Fixed an issue where **Home/End** keys wouldn't move the caret correctly before or after `contenteditable=false` inline elements #TINY-2995 + Fixed an issue where content may have been lost when using permanent bookmarks #TINY-3400 + Fixed the mobile editor to clean up properly when removed #TINY-3445 + Fixed an issue where retrieving the selected content as text didn't create newlines #TINY-3197 + Fixed an issue where typing space between images would cause issues with nbsp not being inserted. #TINY-3346 Version 4.9.3 (2019-01-31) - Added a visualchars_defaul_state setting to the Visualchars Plugin. Patch contributed by mat3e. + Added a visualchars_default_state setting to the Visualchars Plugin. Patch contributed by mat3e. Fixed a bug where scrolling on a page with more than one editor would cause a ResizeWindow event to fire. #TINY-3247 Fixed a bug where if a plugin threw an error during initialisation the whole editor would fail to load. #TINY-3243 Fixed a bug where getContent would include bogus elements when valid_elements setting was set up in a specific way. #TINY-3213 diff --git a/composer.json b/composer.json index 4fd60e23..32e58f5b 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tinymce/tinymce", - "version": "4.9.3", + "version": "4.9.11", "description": "Web based JavaScript HTML WYSIWYG editor control.", "license": [ "LGPL-2.1-only" diff --git a/package.json b/package.json index e2608bda..3143965f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tinymce", - "version": "4.9.3", + "version": "4.9.11", "repository": { "type": "git", "url": "https://github.com/tinymce/tinymce-dist.git" diff --git a/plugins/advlist/plugin.js b/plugins/advlist/plugin.js index bd3467f3..6dc32b66 100644 --- a/plugins/advlist/plugin.js +++ b/plugins/advlist/plugin.js @@ -132,7 +132,7 @@ var advlist = (function () { if (styles.length > 0) { addSplitButton(editor, id, tooltip, cmd, nodeName, styles); } else { - addButton(editor, id, tooltip, cmd, nodeName, styles); + addButton(editor, id, tooltip, cmd, nodeName); } }; var register$1 = function (editor) { diff --git a/plugins/autosave/plugin.js b/plugins/autosave/plugin.js index ddee4d35..4ef15516 100644 --- a/plugins/autosave/plugin.js +++ b/plugins/autosave/plugin.js @@ -1,5 +1,5 @@ (function () { -var autosave = (function () { +var autosave = (function (domGlobals) { 'use strict'; var Cell = function (initial) { @@ -51,9 +51,9 @@ var autosave = (function () { }; var getAutoSavePrefix = function (editor) { var prefix = editor.getParam('autosave_prefix', 'tinymce-autosave-{path}{query}{hash}-{id}-'); - prefix = prefix.replace(/\{path\}/g, document.location.pathname); - prefix = prefix.replace(/\{query\}/g, document.location.search); - prefix = prefix.replace(/\{hash\}/g, document.location.hash); + prefix = prefix.replace(/\{path\}/g, domGlobals.document.location.pathname); + prefix = prefix.replace(/\{query\}/g, domGlobals.document.location.search); + prefix = prefix.replace(/\{hash\}/g, domGlobals.document.location.hash); prefix = prefix.replace(/\{id\}/g, editor.id); return prefix; }; @@ -165,7 +165,7 @@ var autosave = (function () { return msg; }; var setup = function (editor) { - window.onbeforeunload = global$3._beforeUnloadHandler; + domGlobals.window.onbeforeunload = global$3._beforeUnloadHandler; }; var postRender = function (editor, started) { @@ -198,7 +198,7 @@ var autosave = (function () { global.add('autosave', function (editor) { var started = Cell(false); - setup(editor); + setup(); register(editor, started); editor.on('init', function () { if (shouldRestoreWhenEmpty(editor) && editor.dom.isEmpty(editor.getBody())) { @@ -212,5 +212,5 @@ var autosave = (function () { return Plugin; -}()); +}(window)); })(); diff --git a/plugins/autosave/plugin.min.js b/plugins/autosave/plugin.min.js index b2c90a07..1eab7201 100644 --- a/plugins/autosave/plugin.min.js +++ b/plugins/autosave/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var a=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return a(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),i=function(t,e){var n=t||e,r=/^(\d+)([ms]?)$/.exec(""+n);return(r[2]?{s:1e3,m:6e4}[r[2]]:1)*parseInt(n,10)},u=function(t){var e=t.getParam("autosave_prefix","tinymce-autosave-{path}{query}{hash}-{id}-");return e=(e=(e=(e=e.replace(/\{path\}/g,document.location.pathname)).replace(/\{query\}/g,document.location.search)).replace(/\{hash\}/g,document.location.hash)).replace(/\{id\}/g,t.id)},s=function(t,e){var n=t.settings.forced_root_block;return""===(e=o.trim(void 0===e?t.getBody().innerHTML:e))||new RegExp("^<"+n+"[^>]*>((\xa0| |[ \t]|]*>)+?|)|
$","i").test(e)},c=function(t){var e=parseInt(r.getItem(u(t)+"time"),10)||0;return!((new Date).getTime()-e>i(t.settings.autosave_retention,"20m")&&(f(t,!1),1))},f=function(t,e){var n=u(t);r.removeItem(n+"draft"),r.removeItem(n+"time"),!1!==e&&t.fire("RemoveDraft")},l=function(t){var e=u(t);!s(t)&&t.isDirty()&&(r.setItem(e+"draft",t.getContent({format:"raw",no_events:!0})),r.setItem(e+"time",(new Date).getTime().toString()),t.fire("StoreDraft"))},m=function(t){var e=u(t);c(t)&&(t.setContent(r.getItem(e+"draft"),{format:"raw"}),t.fire("RestoreDraft"))},v=function(t,e){var n=i(t.settings.autosave_interval,"30s");e.get()||(setInterval(function(){t.removed||l(t)},n),e.set(!0))},d=function(t){t.undoManager.transact(function(){m(t),f(t)}),t.focus()};function g(r){for(var o=[],t=1;t]*>((\xa0| |[ \t]|]*>)+?|)|
$","i").test(e)},f=function(t){var e=parseInt(r.getItem(s(t)+"time"),10)||0;return!((new Date).getTime()-e>u(t.settings.autosave_retention,"20m")&&(l(t,!1),1))},l=function(t,e){var n=s(t);r.removeItem(n+"draft"),r.removeItem(n+"time"),!1!==e&&t.fire("RemoveDraft")},m=function(t){var e=s(t);!c(t)&&t.isDirty()&&(r.setItem(e+"draft",t.getContent({format:"raw",no_events:!0})),r.setItem(e+"time",(new Date).getTime().toString()),t.fire("StoreDraft"))},v=function(t){var e=s(t);f(t)&&(t.setContent(r.getItem(e+"draft"),{format:"raw"}),t.fire("RestoreDraft"))},d=function(t,e){var n=u(t.settings.autosave_interval,"30s");e.get()||(setInterval(function(){t.removed||m(t)},n),e.set(!0))},g=function(t){t.undoManager.transact(function(){v(t),l(t)}),t.focus()};function y(r){for(var o=[],t=1;t' + env.content + ''; }; @@ -963,5 +963,5 @@ var codesample = (function () { return Plugin; -}()); +}(window)); })(); diff --git a/plugins/codesample/plugin.min.js b/plugins/codesample/plugin.min.js index 8f7373cc..c50f3b25 100644 --- a/plugins/codesample/plugin.min.js +++ b/plugins/codesample/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var n=function(e){var t=e,a=function(){return t};return{get:a,set:function(e){t=e},clone:function(){return n(a())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=function(e){return e.settings.codesample_content_css},a=function(e){return e.settings.codesample_languages},o=function(e){return Math.min(i.DOM.getViewPort().w,e.getParam("codesample_dialog_width",800))},l=function(e){return Math.min(i.DOM.getViewPort().w,e.getParam("codesample_dialog_height",650))},t={},r=t,u=void 0!==t?t:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},c=function(){var c=/\blang(?:uage)?-(?!\*)(\w+)\b/i,S=u.Prism={util:{encode:function(e){return e instanceof o?new o(e.type,S.util.encode(e.content),e.alias):"Array"===S.util.type(e)?e.map(S.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(h instanceof n)){c.lastIndex=0;var m=c.exec(h);if(m){g&&(d=m[1].length);var b=m.index-1+d,y=b+(m=m[0].slice(d)).length,v=h.slice(0,b+1),k=h.slice(y+1),w=[f,1];v&&w.push(v);var x=new n(s,u?S.tokenize(m,u):m,p);w.push(x),k&&w.push(k),Array.prototype.splice.apply(i,w)}}}}}return i},hooks:{all:{},add:function(e,t){var a=S.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=S.hooks.all[e];if(a&&a.length)for(var n=0,i=void 0;i=a[n++];)i(t)}}},o=S.Token=function(e,t,a){this.type=e,this.content=t,this.alias=a};if(o.stringify=function(t,a,e){if("string"==typeof t)return t;if("Array"===S.util.type(t))return t.map(function(e){return o.stringify(e,a,t)}).join("");var n={type:t.type,content:o.stringify(t.content,a,e),tag:"span",classes:["token",t.type],attributes:{},language:a,parent:e};if("comment"===n.type&&(n.attributes.spellcheck="true"),t.alias){var i="Array"===S.util.type(t.alias)?t.alias:[t.alias];Array.prototype.push.apply(n.classes,i)}S.hooks.run("wrap",n);var r="";for(var s in n.attributes)r+=(r?" ":"")+s+'="'+(n.attributes[s]||"")+'"';return"<"+n.tag+' class="'+n.classes.join(" ")+'" '+r+">"+n.content+""},!u.document)return u.addEventListener&&u.addEventListener("message",function(e){var t=JSON.parse(e.data),a=t.language,n=t.code,i=t.immediateClose;u.postMessage(S.highlight(n,S.languages[a],a)),i&&u.close()},!1),u.Prism}();void 0!==r&&(r.Prism=c),c.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\s>\/=.]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},c.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),c.languages.xml=c.languages.markup,c.languages.html=c.languages.markup,c.languages.mathml=c.languages.markup,c.languages.svg=c.languages.markup,c.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},c.languages.css.atrule.inside.rest=c.util.clone(c.languages.css),c.languages.markup&&(c.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:c.languages.markup.tag.inside},rest:c.languages.css},alias:"language-css"}}),c.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:c.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:c.languages.css}},alias:"language-css"}},c.languages.markup.tag)),c.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},c.languages.javascript=c.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),c.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),c.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:c.languages.javascript}},string:/[\s\S]+/}}}),c.languages.markup&&c.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:c.languages.markup.tag.inside},rest:c.languages.javascript},alias:"language-javascript"}}),c.languages.js=c.languages.javascript,c.languages.c=c.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i}),c.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete c.languages.c["class-name"],delete c.languages.c["boolean"],c.languages.csharp=c.languages.extend("clike",{keyword:/\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,string:[/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,/("|')(\\?.)*?\1/],number:/\b-?(0x[\da-f]+|\d*\.?\d+)\b/i}),c.languages.insertBefore("csharp","keyword",{preprocessor:{pattern:/(^\s*)#.*/m,lookbehind:!0}}),c.languages.cpp=c.languages.extend("c",{keyword:/\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,"boolean":/\b(true|false)\b/,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/}),c.languages.insertBefore("cpp","keyword",{"class-name":{pattern:/(class\s+)[a-z0-9_]+/i,lookbehind:!0}}),c.languages.java=c.languages.extend("clike",{keyword:/\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,number:/\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,operator:{pattern:/(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,lookbehind:!0}}),c.languages.php=c.languages.extend("clike",{keyword:/\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,constant:/\b[A-Z0-9_]{2,}\b/,comment:{pattern:/(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,lookbehind:!0}}),c.languages.insertBefore("php","class-name",{"shell-comment":{pattern:/(^|[^\\])#.*/,lookbehind:!0,alias:"comment"}}),c.languages.insertBefore("php","keyword",{delimiter:/\?>|<\?(?:php)?/i,variable:/\$\w+\b/i,"package":{pattern:/(\\|namespace\s+|use\s+)[\w\\]+/,lookbehind:!0,inside:{punctuation:/\\/}}}),c.languages.insertBefore("php","operator",{property:{pattern:/(->)[\w]+/,lookbehind:!0}}),c.languages.markup&&(c.hooks.add("before-highlight",function(t){"php"===t.language&&(t.tokenStack=[],t.backupCode=t.code,t.code=t.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/gi,function(e){return t.tokenStack.push(e),"{{{PHP"+t.tokenStack.length+"}}}"}))}),c.hooks.add("before-insert",function(e){"php"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),c.hooks.add("after-highlight",function(e){if("php"===e.language){for(var t=0,a=void 0;a=e.tokenStack[t];t++)e.highlightedCode=e.highlightedCode.replace("{{{PHP"+(t+1)+"}}}",c.highlight(a,e.grammar,"php").replace(/\$/g,"$$$$"));e.element.innerHTML=e.highlightedCode}}),c.hooks.add("wrap",function(e){"php"===e.language&&"markup"===e.type&&(e.content=e.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g,'$1'))}),c.languages.insertBefore("php","comment",{markup:{pattern:/<[^?]\/?(.*?)>/,inside:c.languages.markup},php:/\{\{\{PHP[0-9]+\}\}\}/})),c.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(?:\\?.)*?\1/,"function":{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)[a-z0-9_]+/i,lookbehind:!0},keyword:/\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(?:True|False)\b/,number:/\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,punctuation:/[{}[\];(),.:]/},function(e){e.languages.ruby=e.languages.extend("clike",{comment:/#(?!\{[^\r\n]*?\}).*/,keyword:/\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/});var t={pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"tag"},rest:e.util.clone(e.languages.ruby)}};e.languages.insertBefore("ruby","keyword",{regex:[{pattern:/%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,inside:{interpolation:t}},{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}],variable:/[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,symbol:/:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.insertBefore("ruby","number",{builtin:/\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,constant:/\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.ruby.string=[{pattern:/%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,inside:{interpolation:t}},{pattern:/("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,inside:{interpolation:t}}]}(c);var g={isCodeSample:function(e){return e&&"PRE"===e.nodeName&&-1!==e.className.indexOf("language-")},trimArg:function(a){return function(e,t){return a(t)}}},d=function(e){var t=e.selection.getNode();return g.isCodeSample(t)?t:null},p=d,f=function(t,a,n){t.undoManager.transact(function(){var e=d(t);n=i.DOM.encode(n),e?(t.dom.setAttrib(e,"class","language-"+a),e.innerHTML=n,c.highlightElement(e),t.selection.select(e)):(t.insertContent('
'+n+"
"),t.selection.select(t.$("#__new").removeAttr("id")[0]))})},h=function(e){var t=d(e);return t?t.textContent:""},m=function(e){var t=a(e);return t||[{text:"HTML/XML",value:"markup"},{text:"JavaScript",value:"javascript"},{text:"CSS",value:"css"},{text:"PHP",value:"php"},{text:"Ruby",value:"ruby"},{text:"Python",value:"python"},{text:"Java",value:"java"},{text:"C",value:"c"},{text:"C#",value:"csharp"},{text:"C++",value:"cpp"}]},b=function(e){var t,a=p(e);return a&&(t=a.className.match(/language-(\w+)/))?t[1]:""},y=function(t){var e=o(t),a=l(t),n=b(t),i=m(t),r=h(t);t.windowManager.open({title:"Insert/Edit code sample",minWidth:e,minHeight:a,layout:"flex",direction:"column",align:"stretch",body:[{type:"listbox",name:"language",label:"Language",maxWidth:200,value:n,values:i},{type:"textbox",name:"code",multiline:!0,spellcheck:!1,ariaLabel:"Code view",flex:1,style:"direction: ltr; text-align: left",classes:"monospace",value:r,autofocus:!0}],onSubmit:function(e){f(t,e.data.language,e.data.code)}})},v=function(t){t.addCommand("codesample",function(){var e=t.selection.getNode();t.selection.isCollapsed()||g.isCodeSample(e)?y(t):t.formatter.toggle("code")})},k=function(a){var i=a.$;a.on("PreProcess",function(e){i("pre[contenteditable=false]",e.node).filter(g.trimArg(g.isCodeSample)).each(function(e,t){var a=i(t),n=t.textContent;a.attr("class",i.trim(a.attr("class"))),a.removeAttr("contentEditable"),a.empty().append(i("").each(function(){this.textContent=n}))})}),a.on("SetContent",function(){var e=i("pre").filter(g.trimArg(g.isCodeSample)).filter(function(e,t){return"false"!==t.contentEditable});e.length&&a.undoManager.transact(function(){e.each(function(e,t){i(t).find("br").each(function(e,t){t.parentNode.replaceChild(a.getDoc().createTextNode("\n"),t)}),t.contentEditable=!1,t.innerHTML=a.dom.encode(t.textContent),c.highlightElement(t),t.className=i.trim(t.className)})})})},w=function(e,t,a,n){var i,r=s(e);e.inline&&a.get()||!e.inline&&n.get()||(e.inline?a.set(!0):n.set(!0),!1!==r&&(i=e.dom.create("link",{rel:"stylesheet",href:r||t+"/css/prism.css"}),e.getDoc().getElementsByTagName("head")[0].appendChild(i)))},x=function(e){e.addButton("codesample",{cmd:"codesample",title:"Insert/Edit code sample"}),e.addMenuItem("codesample",{cmd:"codesample",text:"Code sample",icon:"codesample"})},S=n(!1);e.add("codesample",function(t,e){var a=n(!1);k(t),x(t),v(t),t.on("init",function(){w(t,e,S,a)}),t.on("dblclick",function(e){g.isCodeSample(e.target)&&y(t)})})}(); \ No newline at end of file +!function(u){"use strict";var n=function(e){var t=e,a=function(){return t};return{get:a,set:function(e){t=e},clone:function(){return n(a())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),i=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=function(e){return e.settings.codesample_content_css},a=function(e){return e.settings.codesample_languages},o=function(e){return Math.min(i.DOM.getViewPort().w,e.getParam("codesample_dialog_width",800))},l=function(e){return Math.min(i.DOM.getViewPort().w,e.getParam("codesample_dialog_height",650))},t={},r=t,g=void 0!==t?t:"undefined"!=typeof WorkerGlobalScope&&u.self instanceof WorkerGlobalScope?u.self:{},c=function(){var c=/\blang(?:uage)?-(?!\*)(\w+)\b/i,S=g.Prism={util:{encode:function(e){return e instanceof o?new o(e.type,S.util.encode(e.content),e.alias):"Array"===S.util.type(e)?e.map(S.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(h instanceof n)){c.lastIndex=0;var m=c.exec(h);if(m){g&&(d=m[1].length);var b=m.index-1+d,y=b+(m=m[0].slice(d)).length,v=h.slice(0,b+1),k=h.slice(y+1),w=[f,1];v&&w.push(v);var x=new n(s,u?S.tokenize(m,u):m,p);w.push(x),k&&w.push(k),Array.prototype.splice.apply(i,w)}}}}}return i},hooks:{all:{},add:function(e,t){var a=S.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=S.hooks.all[e];if(a&&a.length)for(var n=0,i=void 0;i=a[n++];)i(t)}}},o=S.Token=function(e,t,a){this.type=e,this.content=t,this.alias=a};if(o.stringify=function(t,a,e){if("string"==typeof t)return t;if("Array"===S.util.type(t))return t.map(function(e){return o.stringify(e,a,t)}).join("");var n={type:t.type,content:o.stringify(t.content,a,e),tag:"span",classes:["token",t.type],attributes:{},language:a,parent:e};if("comment"===n.type&&(n.attributes.spellcheck="true"),t.alias){var i="Array"===S.util.type(t.alias)?t.alias:[t.alias];Array.prototype.push.apply(n.classes,i)}S.hooks.run("wrap",n);var r="";for(var s in n.attributes)r+=(r?" ":"")+s+'="'+(n.attributes[s]||"")+'"';return"<"+n.tag+' class="'+n.classes.join(" ")+'" '+r+">"+n.content+""},!g.document)return g.addEventListener&&g.addEventListener("message",function(e){var t=JSON.parse(e.data),a=t.language,n=t.code,i=t.immediateClose;g.postMessage(S.highlight(n,S.languages[a],a)),i&&g.close()},!1),g.Prism}();void 0!==r&&(r.Prism=c),c.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\s>\/=.]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},c.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),c.languages.xml=c.languages.markup,c.languages.html=c.languages.markup,c.languages.mathml=c.languages.markup,c.languages.svg=c.languages.markup,c.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},c.languages.css.atrule.inside.rest=c.util.clone(c.languages.css),c.languages.markup&&(c.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:c.languages.markup.tag.inside},rest:c.languages.css},alias:"language-css"}}),c.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:c.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:c.languages.css}},alias:"language-css"}},c.languages.markup.tag)),c.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},c.languages.javascript=c.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),c.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),c.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:c.languages.javascript}},string:/[\s\S]+/}}}),c.languages.markup&&c.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:c.languages.markup.tag.inside},rest:c.languages.javascript},alias:"language-javascript"}}),c.languages.js=c.languages.javascript,c.languages.c=c.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i}),c.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete c.languages.c["class-name"],delete c.languages.c["boolean"],c.languages.csharp=c.languages.extend("clike",{keyword:/\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,string:[/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,/("|')(\\?.)*?\1/],number:/\b-?(0x[\da-f]+|\d*\.?\d+)\b/i}),c.languages.insertBefore("csharp","keyword",{preprocessor:{pattern:/(^\s*)#.*/m,lookbehind:!0}}),c.languages.cpp=c.languages.extend("c",{keyword:/\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,"boolean":/\b(true|false)\b/,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/}),c.languages.insertBefore("cpp","keyword",{"class-name":{pattern:/(class\s+)[a-z0-9_]+/i,lookbehind:!0}}),c.languages.java=c.languages.extend("clike",{keyword:/\b(abstract|continue|for|new|switch|assert|default|goto|package|synchronized|boolean|do|if|private|this|break|double|implements|protected|throw|byte|else|import|public|throws|case|enum|instanceof|return|transient|catch|extends|int|short|try|char|final|interface|static|void|class|finally|long|strictfp|volatile|const|float|native|super|while)\b/,number:/\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+(?:e[+-]?\d+)?[df]?\b/i,operator:{pattern:/(^|[^.])(?:\+[+=]?|-[-=]?|!=?|<>?>?=?|==?|&[&=]?|\|[|=]?|\*=?|\/=?|%=?|\^=?|[?:~])/m,lookbehind:!0}}),c.languages.php=c.languages.extend("clike",{keyword:/\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch)\b/i,constant:/\b[A-Z0-9_]{2,}\b/,comment:{pattern:/(^|[^\\])(?:\/\*[\w\W]*?\*\/|\/\/.*)/,lookbehind:!0}}),c.languages.insertBefore("php","class-name",{"shell-comment":{pattern:/(^|[^\\])#.*/,lookbehind:!0,alias:"comment"}}),c.languages.insertBefore("php","keyword",{delimiter:/\?>|<\?(?:php)?/i,variable:/\$\w+\b/i,"package":{pattern:/(\\|namespace\s+|use\s+)[\w\\]+/,lookbehind:!0,inside:{punctuation:/\\/}}}),c.languages.insertBefore("php","operator",{property:{pattern:/(->)[\w]+/,lookbehind:!0}}),c.languages.markup&&(c.hooks.add("before-highlight",function(t){"php"===t.language&&(t.tokenStack=[],t.backupCode=t.code,t.code=t.code.replace(/(?:<\?php|<\?)[\w\W]*?(?:\?>)/gi,function(e){return t.tokenStack.push(e),"{{{PHP"+t.tokenStack.length+"}}}"}))}),c.hooks.add("before-insert",function(e){"php"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),c.hooks.add("after-highlight",function(e){if("php"===e.language){for(var t=0,a=void 0;a=e.tokenStack[t];t++)e.highlightedCode=e.highlightedCode.replace("{{{PHP"+(t+1)+"}}}",c.highlight(a,e.grammar,"php").replace(/\$/g,"$$$$"));e.element.innerHTML=e.highlightedCode}}),c.hooks.add("wrap",function(e){"php"===e.language&&"markup"===e.type&&(e.content=e.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g,'$1'))}),c.languages.insertBefore("php","comment",{markup:{pattern:/<[^?]\/?(.*?)>/,inside:c.languages.markup},php:/\{\{\{PHP[0-9]+\}\}\}/})),c.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(?:\\?.)*?\1/,"function":{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)[a-z0-9_]+/i,lookbehind:!0},keyword:/\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(?:True|False)\b/,number:/\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,punctuation:/[{}[\];(),.:]/},function(e){e.languages.ruby=e.languages.extend("clike",{comment:/#(?!\{[^\r\n]*?\}).*/,keyword:/\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/});var t={pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"tag"},rest:e.util.clone(e.languages.ruby)}};e.languages.insertBefore("ruby","keyword",{regex:[{pattern:/%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,inside:{interpolation:t}},{pattern:/%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,inside:{interpolation:t}},{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}],variable:/[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,symbol:/:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.insertBefore("ruby","number",{builtin:/\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,constant:/\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.ruby.string=[{pattern:/%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,inside:{interpolation:t}},{pattern:/%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,inside:{interpolation:t}},{pattern:/("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,inside:{interpolation:t}}]}(c);var d={isCodeSample:function(e){return e&&"PRE"===e.nodeName&&-1!==e.className.indexOf("language-")},trimArg:function(a){return function(e,t){return a(t)}}},p=function(e){var t=e.selection.getNode();return d.isCodeSample(t)?t:null},f=p,h=function(t,a,n){t.undoManager.transact(function(){var e=p(t);n=i.DOM.encode(n),e?(t.dom.setAttrib(e,"class","language-"+a),e.innerHTML=n,c.highlightElement(e),t.selection.select(e)):(t.insertContent('
'+n+"
"),t.selection.select(t.$("#__new").removeAttr("id")[0]))})},m=function(e){var t=p(e);return t?t.textContent:""},b=function(e){var t=a(e);return t||[{text:"HTML/XML",value:"markup"},{text:"JavaScript",value:"javascript"},{text:"CSS",value:"css"},{text:"PHP",value:"php"},{text:"Ruby",value:"ruby"},{text:"Python",value:"python"},{text:"Java",value:"java"},{text:"C",value:"c"},{text:"C#",value:"csharp"},{text:"C++",value:"cpp"}]},y=function(e){var t,a=f(e);return a&&(t=a.className.match(/language-(\w+)/))?t[1]:""},v=function(t){var e=o(t),a=l(t),n=y(t),i=b(t),r=m(t);t.windowManager.open({title:"Insert/Edit code sample",minWidth:e,minHeight:a,layout:"flex",direction:"column",align:"stretch",body:[{type:"listbox",name:"language",label:"Language",maxWidth:200,value:n,values:i},{type:"textbox",name:"code",multiline:!0,spellcheck:!1,ariaLabel:"Code view",flex:1,style:"direction: ltr; text-align: left",classes:"monospace",value:r,autofocus:!0}],onSubmit:function(e){h(t,e.data.language,e.data.code)}})},k=function(t){t.addCommand("codesample",function(){var e=t.selection.getNode();t.selection.isCollapsed()||d.isCodeSample(e)?v(t):t.formatter.toggle("code")})},w=function(a){var i=a.$;a.on("PreProcess",function(e){i("pre[contenteditable=false]",e.node).filter(d.trimArg(d.isCodeSample)).each(function(e,t){var a=i(t),n=t.textContent;a.attr("class",i.trim(a.attr("class"))),a.removeAttr("contentEditable"),a.empty().append(i("").each(function(){this.textContent=n}))})}),a.on("SetContent",function(){var e=i("pre").filter(d.trimArg(d.isCodeSample)).filter(function(e,t){return"false"!==t.contentEditable});e.length&&a.undoManager.transact(function(){e.each(function(e,t){i(t).find("br").each(function(e,t){t.parentNode.replaceChild(a.getDoc().createTextNode("\n"),t)}),t.contentEditable=!1,t.innerHTML=a.dom.encode(t.textContent),c.highlightElement(t),t.className=i.trim(t.className)})})})},x=function(e,t,a,n){var i,r=s(e);e.inline&&a.get()||!e.inline&&n.get()||(e.inline?a.set(!0):n.set(!0),!1!==r&&(i=e.dom.create("link",{rel:"stylesheet",href:r||t+"/css/prism.css"}),e.getDoc().getElementsByTagName("head")[0].appendChild(i)))},S=function(e){e.addButton("codesample",{cmd:"codesample",title:"Insert/Edit code sample"}),e.addMenuItem("codesample",{cmd:"codesample",text:"Code sample",icon:"codesample"})},C=n(!1);e.add("codesample",function(t,e){var a=n(!1);w(t),S(t),k(t),t.on("init",function(){x(t,e,C,a)}),t.on("dblclick",function(e){d.isCodeSample(e.target)&&v(t)})})}(window); \ No newline at end of file diff --git a/plugins/fullscreen/plugin.js b/plugins/fullscreen/plugin.js index ee21331c..1c5c00ea 100644 --- a/plugins/fullscreen/plugin.js +++ b/plugins/fullscreen/plugin.js @@ -1,5 +1,5 @@ (function () { -var fullscreen = (function () { +var fullscreen = (function (domGlobals) { 'use strict'; var Cell = function (initial) { @@ -42,8 +42,8 @@ var fullscreen = (function () { var getWindowSize = function () { var w; var h; - var win = window; - var doc = document; + var win = domGlobals.window; + var doc = domGlobals.document; var body = doc.body; if (body.offsetWidth) { w = body.offsetWidth; @@ -66,11 +66,11 @@ var fullscreen = (function () { }; }; var setScrollPos = function (pos) { - window.scrollTo(pos.x, pos.y); + domGlobals.window.scrollTo(pos.x, pos.y); }; var toggleFullscreen = function (editor, fullscreenState) { - var body = document.body; - var documentElement = document.documentElement; + var body = domGlobals.document.body; + var documentElement = domGlobals.document.documentElement; var editorContainerStyle; var editorContainer, iframe, iframeStyle; var fullscreenInfo = fullscreenState.get(); @@ -78,7 +78,7 @@ var fullscreen = (function () { DOM.setStyle(iframe, 'height', getWindowSize().h - (editorContainer.clientHeight - iframe.clientHeight)); }; var removeResize = function () { - DOM.unbind(window, 'resize', resize); + DOM.unbind(domGlobals.window, 'resize', resize); }; editorContainer = editor.getContainer(); editorContainerStyle = editorContainer.style; @@ -99,7 +99,7 @@ var fullscreen = (function () { DOM.addClass(body, 'mce-fullscreen'); DOM.addClass(documentElement, 'mce-fullscreen'); DOM.addClass(editorContainer, 'mce-fullscreen'); - DOM.bind(window, 'resize', resize); + DOM.bind(domGlobals.window, 'resize', resize); editor.on('remove', removeResize); resize(); fullscreenState.set(newFullScreenInfo); @@ -117,7 +117,7 @@ var fullscreen = (function () { DOM.removeClass(documentElement, 'mce-fullscreen'); DOM.removeClass(editorContainer, 'mce-fullscreen'); setScrollPos(fullscreenInfo.scrollPos); - DOM.unbind(window, 'resize', fullscreenInfo.resizeHandler); + DOM.unbind(domGlobals.window, 'resize', fullscreenInfo.resizeHandler); editor.off('remove', fullscreenInfo.removeHandler); fullscreenState.set(null); Events.fireFullscreenStateChanged(editor, false); @@ -173,5 +173,5 @@ var fullscreen = (function () { return Plugin; -}()); +}(window)); })(); diff --git a/plugins/fullscreen/plugin.min.js b/plugins/fullscreen/plugin.min.js index cd4eb5ed..259afc9a 100644 --- a/plugins/fullscreen/plugin.min.js +++ b/plugins/fullscreen/plugin.min.js @@ -1 +1 @@ -!function(){"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"),m=function(e,n){e.fire("FullscreenStateChanged",{state:n})},g=n.DOM,r=function(e,n){var t,r,l,i,o,c,s=document.body,u=document.documentElement,d=n.get(),a=function(){var e,n,t,i;g.setStyle(l,"height",(t=window,i=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(){g.unbind(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),g.removeClass(s,"mce-fullscreen"),g.removeClass(u,"mce-fullscreen"),g.removeClass(r,"mce-fullscreen"),o=d.scrollPos,window.scrollTo(o.x,o.y),g.unbind(window,"resize",d.resizeHandler),e.off("remove",d.removeHandler),n.set(null),m(e,!1);else{var f={scrollPos:(c=g.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="",g.addClass(s,"mce-fullscreen"),g.addClass(u,"mce-fullscreen"),g.addClass(r,"mce-fullscreen"),g.bind(window,"resize",a),e.on("remove",h),a(),n.set(f),m(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)})}(); \ No newline at end of file +!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/plugins/help/plugin.js b/plugins/help/plugin.js index bf7da8f8..b26f217f 100644 --- a/plugins/help/plugin.js +++ b/plugins/help/plugin.js @@ -4,6 +4,8 @@ var help = (function () { var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); + var noop = function () { + }; var constant = function (value) { return function () { return value; @@ -35,8 +37,6 @@ var help = (function () { var never = constant(false); var always = constant(true); - var never$1 = never; - var always$1 = always; var none = function () { return NONE; }; @@ -44,43 +44,33 @@ var help = (function () { var eq = function (o) { return o.isNone(); }; - var call$$1 = function (thunk) { + var call = function (thunk) { return thunk(); }; var id = function (n) { return n; }; - var noop$$1 = function () { - }; - var nul = function () { - return null; - }; - var undef = function () { - return undefined; - }; var me = { fold: function (n, s) { return n(); }, - is: never$1, - isSome: never$1, - isNone: always$1, + is: never, + isSome: never, + isNone: always, getOr: id, - getOrThunk: call$$1, + getOrThunk: call, getOrDie: function (msg) { throw new Error(msg || 'error: getOrDie called on none.'); }, - getOrNull: nul, - getOrUndefined: undef, + getOrNull: constant(null), + getOrUndefined: constant(undefined), or: id, - orThunk: call$$1, + orThunk: call, map: none, - ap: none, - each: noop$$1, + each: noop, bind: none, - flatten: none, - exists: never$1, - forall: always$1, + exists: never, + forall: always, filter: none, equals: eq, equals_: eq, @@ -89,20 +79,16 @@ var help = (function () { }, toString: constant('none()') }; - if (Object.freeze) + if (Object.freeze) { Object.freeze(me); + } return me; }(); var some = function (a) { - var constant_a = function () { - return a; - }; + var constant_a = constant(a); var self = function () { return me; }; - var map = function (f) { - return some(f(a)); - }; var bind = function (f) { return f(a); }; @@ -113,8 +99,8 @@ var help = (function () { is: function (v) { return a === v; }, - isSome: always$1, - isNone: never$1, + isSome: always, + isNone: never, getOr: constant_a, getOrThunk: constant_a, getOrDie: constant_a, @@ -122,35 +108,31 @@ var help = (function () { getOrUndefined: constant_a, or: self, orThunk: self, - map: map, - ap: function (optfab) { - return optfab.fold(none, function (fab) { - return some(fab(a)); - }); + map: function (f) { + return some(f(a)); }, each: function (f) { f(a); }, bind: bind, - flatten: constant_a, 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$1, function (b) { + return o.fold(never, function (b) { return elementEq(a, b); }); - }, - toArray: function () { - return [a]; - }, - toString: function () { - return 'some(' + a + ')'; } }; return me; @@ -165,13 +147,16 @@ var help = (function () { }; var typeOf = function (x) { - if (x === null) + if (x === null) { return 'null'; + } var t = typeof x; - if (t === 'object' && Array.prototype.isPrototypeOf(x)) + if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { return 'array'; - if (t === 'object' && String.prototype.isPrototypeOf(x)) + } + if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { return 'string'; + } return t; }; var isType = function (type) { @@ -181,16 +166,11 @@ var help = (function () { }; var isFunction = isType('function'); - var rawIndexOf = function () { - var pIndexOf = Array.prototype.indexOf; - var fastIndex = function (xs, x) { - return pIndexOf.call(xs, x); - }; - var slowIndex = function (xs, x) { - return slowIndexOf(xs, x); - }; - return pIndexOf === undefined ? slowIndex : fastIndex; - }(); + var nativeSlice = Array.prototype.slice; + var nativeIndexOf = Array.prototype.indexOf; + var rawIndexOf = function (ts, t) { + return nativeIndexOf.call(ts, t); + }; var contains = function (xs, x) { return rawIndexOf(xs, x) > -1; }; @@ -199,7 +179,7 @@ var help = (function () { var r = new Array(len); for (var i = 0; i < len; i++) { var x = xs[i]; - r[i] = f(x, i, xs); + r[i] = f(x, i); } return r; }; @@ -207,7 +187,7 @@ var help = (function () { var r = []; for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; - if (pred(x, i, xs)) { + if (pred(x, i)) { r.push(x); } } @@ -216,23 +196,14 @@ var help = (function () { var find = function (xs, pred) { for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; - if (pred(x, i, xs)) { + if (pred(x, i)) { return Option.some(x); } } return Option.none(); }; - var slowIndexOf = function (xs, x) { - for (var i = 0, len = xs.length; i < len; ++i) { - if (xs[i] === x) { - return i; - } - } - return -1; - }; - var slice = Array.prototype.slice; var from$1 = isFunction(Array.from) ? Array.from : function (x) { - return slice.call(x); + return nativeSlice.call(x); }; var global$1 = tinymce.util.Tools.resolve('tinymce.util.I18n'); @@ -560,8 +531,8 @@ var help = (function () { }); }; var getPluginKeys = function (editor) { - var keys$$1 = keys(editor.plugins); - return editor.settings.forced_plugins === undefined ? keys$$1 : filter(keys$$1, not(curry(contains, editor.settings.forced_plugins))); + var keys$1 = keys(editor.plugins); + return editor.settings.forced_plugins === undefined ? keys$1 : filter(keys$1, not(curry(contains, editor.settings.forced_plugins))); }; var pluginLister = function (editor) { var pluginKeys = getPluginKeys(editor); diff --git a/plugins/help/plugin.min.js b/plugins/help/plugin.min.js index a598b6c4..67cde482 100644 --- a/plugins/help/plugin.min.js +++ b/plugins/help/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(e){return function(){return e}};function c(r){for(var o=[],e=1;e'+C.translate(e.action)+""+e.shortcut+"";var t}).join("");return{title:"Handy Shortcuts",type:"container",style:"overflow-y: auto; overflow-x: hidden; max-height: 250px",items:[{type:"container",html:'
"+e+"
'+C.translate("Action")+""+C.translate("Shortcut")+"
"}]}},P=Object.keys,_=[{key:"advlist",name:"Advanced List"},{key:"anchor",name:"Anchor"},{key:"autolink",name:"Autolink"},{key:"autoresize",name:"Autoresize"},{key:"autosave",name:"Autosave"},{key:"bbcode",name:"BBCode"},{key:"charmap",name:"Character Map"},{key:"code",name:"Code"},{key:"codesample",name:"Code Sample"},{key:"colorpicker",name:"Color Picker"},{key:"compat3x",name:"3.x Compatibility"},{key:"contextmenu",name:"Context Menu"},{key:"directionality",name:"Directionality"},{key:"emoticons",name:"Emoticons"},{key:"fullpage",name:"Full Page"},{key:"fullscreen",name:"Full Screen"},{key:"help",name:"Help"},{key:"hr",name:"Horizontal Rule"},{key:"image",name:"Image"},{key:"imagetools",name:"Image Tools"},{key:"importcss",name:"Import CSS"},{key:"insertdatetime",name:"Insert Date/Time"},{key:"legacyoutput",name:"Legacy Output"},{key:"link",name:"Link"},{key:"lists",name:"Lists"},{key:"media",name:"Media"},{key:"nonbreaking",name:"Nonbreaking"},{key:"noneditable",name:"Noneditable"},{key:"pagebreak",name:"Page Break"},{key:"paste",name:"Paste"},{key:"preview",name:"Preview"},{key:"print",name:"Print"},{key:"save",name:"Save"},{key:"searchreplace",name:"Search and Replace"},{key:"spellchecker",name:"Spell Checker"},{key:"tabfocus",name:"Tab Focus"},{key:"table",name:"Table"},{key:"template",name:"Template"},{key:"textcolor",name:"Text Color"},{key:"textpattern",name:"Text Pattern"},{key:"toc",name:"Table of Contents"},{key:"visualblocks",name:"Visual Blocks"},{key:"visualchars",name:"Visual Characters"},{key:"wordcount",name:"Word Count"}],H=c(function(e,o){return e.replace(/\$\{([^{}]*)\}/g,function(e,t){var n,r=o[t];return"string"==(n=typeof r)||"number"===n?r.toString():e})},'${name}'),F=function(t,n){return function(e,t){for(var n=0,r=e.length;n"+F(t,e)+""}),i=a.length,l=a.join("");return"

"+C.translate(["Plugins installed ({0}):",i])+"

    "+l+"
"},E=function(e){return{title:"Plugins",type:"container",style:"overflow-y: auto; overflow-x: hidden;",layout:"flex",padding:10,spacing:10,items:[(t=e,{type:"container",html:'
'+M(t)+"
",flex:1}),{type:"container",html:'

'+C.translate("Premium plugins:")+'

  • PowerPaste
  • Spell Checker Pro
  • Accessibility Checker
  • Advanced Code Editor
  • Enhanced Media Embed
  • Link Checker

'+C.translate("Learn more...")+"

",flex:1}]};var t},I=tinymce.util.Tools.resolve("tinymce.EditorManager"),j=function(){var e,t,n='TinyMCE '+(e=I.majorVersion,t=I.minorVersion,0===e.indexOf("@")?"X.X.X":e+"."+t)+"";return[{type:"label",html:C.translate(["You are using {0}",n])},{type:"spacer",flex:1},{text:"Close",onclick:function(){this.parent().parent().close()}}]},L=function(e,t){return function(){e.windowManager.open({title:"Help",bodyType:"tabpanel",layout:"flex",body:[T(),E(e)],buttons:j(),onPostRender:function(){this.getEl("title").innerHTML='TinyMCE Logo'}})}},B=function(e,t){e.addCommand("mceHelp",L(e,t))},N=function(e,t){e.addButton("help",{icon:"help",onclick:L(e,t)}),e.addMenuItem("help",{text:"Help",icon:"help",context:"help",onclick:L(e,t)})};e.add("help",function(e,t){N(e,t),B(e,t),e.shortcuts.add("Alt+0","Open help dialog","mceHelp")})}(); \ No newline at end of file +!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=function(){},a=function(e){return function(){return e}};function l(r){for(var o=[],e=1;e'+v.translate(e.action)+""+e.shortcut+"";var t}).join("");return{title:"Handy Shortcuts",type:"container",style:"overflow-y: auto; overflow-x: hidden; max-height: 250px",items:[{type:"container",html:'
"+e+"
'+v.translate("Action")+""+v.translate("Shortcut")+"
"}]}},S=Object.keys,O=[{key:"advlist",name:"Advanced List"},{key:"anchor",name:"Anchor"},{key:"autolink",name:"Autolink"},{key:"autoresize",name:"Autoresize"},{key:"autosave",name:"Autosave"},{key:"bbcode",name:"BBCode"},{key:"charmap",name:"Character Map"},{key:"code",name:"Code"},{key:"codesample",name:"Code Sample"},{key:"colorpicker",name:"Color Picker"},{key:"compat3x",name:"3.x Compatibility"},{key:"contextmenu",name:"Context Menu"},{key:"directionality",name:"Directionality"},{key:"emoticons",name:"Emoticons"},{key:"fullpage",name:"Full Page"},{key:"fullscreen",name:"Full Screen"},{key:"help",name:"Help"},{key:"hr",name:"Horizontal Rule"},{key:"image",name:"Image"},{key:"imagetools",name:"Image Tools"},{key:"importcss",name:"Import CSS"},{key:"insertdatetime",name:"Insert Date/Time"},{key:"legacyoutput",name:"Legacy Output"},{key:"link",name:"Link"},{key:"lists",name:"Lists"},{key:"media",name:"Media"},{key:"nonbreaking",name:"Nonbreaking"},{key:"noneditable",name:"Noneditable"},{key:"pagebreak",name:"Page Break"},{key:"paste",name:"Paste"},{key:"preview",name:"Preview"},{key:"print",name:"Print"},{key:"save",name:"Save"},{key:"searchreplace",name:"Search and Replace"},{key:"spellchecker",name:"Spell Checker"},{key:"tabfocus",name:"Tab Focus"},{key:"table",name:"Table"},{key:"template",name:"Template"},{key:"textcolor",name:"Text Color"},{key:"textpattern",name:"Text Pattern"},{key:"toc",name:"Table of Contents"},{key:"visualblocks",name:"Visual Blocks"},{key:"visualchars",name:"Visual Characters"},{key:"wordcount",name:"Word Count"}],T=l(function(e,o){return e.replace(/\$\{([^{}]*)\}/g,function(e,t){var n,r=o[t];return"string"==(n=typeof r)||"number"===n?r.toString():e})},'${name}'),P=function(t,n){return function(e,t){for(var n=0,r=e.length;n"+P(t,e)+""}),i=a.length,c=a.join("");return"

"+v.translate(["Plugins installed ({0}):",i])+"

    "+c+"
"},H=function(e){return{title:"Plugins",type:"container",style:"overflow-y: auto; overflow-x: hidden;",layout:"flex",padding:10,spacing:10,items:[(t=e,{type:"container",html:'
'+_(t)+"
",flex:1}),{type:"container",html:'

'+v.translate("Premium plugins:")+'

  • PowerPaste
  • Spell Checker Pro
  • Accessibility Checker
  • Advanced Code Editor
  • Enhanced Media Embed
  • Link Checker

'+v.translate("Learn more...")+"

",flex:1}]};var t},F=tinymce.util.Tools.resolve("tinymce.EditorManager"),M=function(){var e,t,n='TinyMCE '+(e=F.majorVersion,t=F.minorVersion,0===e.indexOf("@")?"X.X.X":e+"."+t)+"";return[{type:"label",html:v.translate(["You are using {0}",n])},{type:"spacer",flex:1},{text:"Close",onclick:function(){this.parent().parent().close()}}]},E=function(e,t){return function(){e.windowManager.open({title:"Help",bodyType:"tabpanel",layout:"flex",body:[w(),H(e)],buttons:M(),onPostRender:function(){this.getEl("title").innerHTML='TinyMCE Logo'}})}},I=function(e,t){e.addCommand("mceHelp",E(e,t))},j=function(e,t){e.addButton("help",{icon:"help",onclick:E(e,t)}),e.addMenuItem("help",{text:"Help",icon:"help",context:"help",onclick:E(e,t)})};e.add("help",function(e,t){j(e,t),I(e,t),e.shortcuts.add("Alt+0","Open help dialog","mceHelp")})}(); \ No newline at end of file diff --git a/plugins/image/plugin.js b/plugins/image/plugin.js index ba68a9bd..62ccc9da 100644 --- a/plugins/image/plugin.js +++ b/plugins/image/plugin.js @@ -1,5 +1,5 @@ (function () { -var image = (function () { +var image = (function (domGlobals) { 'use strict'; var global = tinymce.util.Tools.resolve('tinymce.PluginManager'); @@ -63,12 +63,13 @@ var image = (function () { getUploadCredentials: getUploadCredentials }; - var Global = typeof window !== 'undefined' ? window : Function('return this;')(); + 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) + for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) { o = o[parts[i]]; + } return o; }; var resolve = function (p, scope) { @@ -81,8 +82,9 @@ var image = (function () { }; var getOrDie = function (name, scope) { var actual = unsafe(name, scope); - if (actual === undefined || actual === null) - throw name + ' not available on this browser'; + if (actual === undefined || actual === null) { + throw new Error(name + ' not available on this browser'); + } return actual; }; var Global$1 = { getOrDie: getOrDie }; @@ -102,7 +104,7 @@ var image = (function () { return Math.max(parseInt(val1, 10), parseInt(val2, 10)); }; var getImageSize = function (url, callback) { - var img = document.createElement('img'); + var img = domGlobals.document.createElement('img'); function done(width, height) { if (img.parentNode) { img.parentNode.removeChild(img); @@ -125,7 +127,7 @@ var image = (function () { style.position = 'fixed'; style.bottom = style.left = '0px'; style.width = style.height = 'auto'; - document.body.appendChild(img); + domGlobals.document.body.appendChild(img); img.src = url; }; var buildListItems = function (inputList, itemCallback, startItems) { @@ -255,17 +257,20 @@ var image = (function () { var baseMerge = function (merger) { return function () { var objects = new Array(arguments.length); - for (var i = 0; i < objects.length; i++) + for (var i = 0; i < objects.length; i++) { objects[i] = arguments[i]; - if (objects.length === 0) + } + 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) + for (var key in curObject) { if (hasOwnProperty.call(curObject, key)) { ret[key] = merger(ret[key], curObject[key]); } + } } return ret; }; @@ -294,21 +299,21 @@ var image = (function () { return ''; } }; - var getAttrib = function (image, name$$1) { - if (image.hasAttribute(name$$1)) { - return image.getAttribute(name$$1); + var getAttrib = function (image, name) { + if (image.hasAttribute(name)) { + return image.getAttribute(name); } else { return ''; } }; - var getStyle = function (image, name$$1) { - return image.style[name$$1] ? image.style[name$$1] : ''; + 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$$1, value) { - image.setAttribute(name$$1, value); + var setAttrib = function (image, name, value) { + image.setAttribute(name, value); }; var wrapInFigure = function (image) { var figureElm = DOM.create('figure', { class: 'image' }); @@ -339,21 +344,21 @@ var image = (function () { image.removeAttribute('style'); } }; - var setSize = function (name$$1, normalizeCss) { - return function (image, name$$1, value) { - if (image.style[name$$1]) { - image.style[name$$1] = Utils.addPixelSuffix(value); + 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$$1, value); + setAttrib(image, name, value); } }; }; - var getSize = function (image, name$$1) { - if (image.style[name$$1]) { - return Utils.removePixelSuffix(image.style[name$$1]); + var getSize = function (image, name) { + if (image.style[name]) { + return Utils.removePixelSuffix(image.style[name]); } else { - return getAttrib(image, name$$1); + return getAttrib(image, name); } }; var setHspace = function (image, value) { @@ -396,7 +401,7 @@ var image = (function () { }; }; var getStyleValue = function (normalizeCss, data) { - var image = document.createElement('img'); + var image = domGlobals.document.createElement('img'); setAttrib(image, 'style', data.style); if (getHspace(image) || data.hspace !== '') { setHspace(image, data.hspace); @@ -413,7 +418,7 @@ var image = (function () { return normalizeCss(image.getAttribute('style')); }; var create = function (normalizeCss, data) { - var image = document.createElement('img'); + var image = domGlobals.document.createElement('img'); write(normalizeCss, merge(data, { caption: false }), image); setAttrib(image, 'alt', data.alt); if (data.caption) { @@ -442,13 +447,13 @@ var image = (function () { borderStyle: getStyle(image, 'borderStyle') }; }; - var updateProp = function (image, oldData, newData, name$$1, set) { - if (newData[name$$1] !== oldData[name$$1]) { - set(image, name$$1, newData[name$$1]); + 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$$1, value) { + return function (image, name, value) { set(image, value); normalizeStyle(image, normalizeCss); }; @@ -952,7 +957,7 @@ var image = (function () { } success(pathJoin(settings.basePath, json.location)); }; - formData = new FormData(); + formData = new domGlobals.FormData(); formData.append('file', blobInfo.blob(), blobInfo.filename()); xhr.send(formData); }; @@ -1200,5 +1205,5 @@ var image = (function () { return Plugin; -}()); +}(window)); })(); diff --git a/plugins/image/plugin.min.js b/plugins/image/plugin.min.js index 2bb78be4..23473aa7 100644 --- a/plugins/image/plugin.min.js +++ b/plugins/image/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var i,e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=function(e){return!1!==e.settings.image_dimensions},l=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},u=function(e){return e.getParam("image_list",!1)},c=function(e){return e.getParam("images_upload_url",!1)},s=function(e){return e.getParam("images_upload_handler",!1)},g=function(e){return e.getParam("images_upload_url")},f=function(e){return e.getParam("images_upload_handler")},p=function(e){return e.getParam("images_upload_base_path")},h=function(e){return e.getParam("images_upload_credentials")},v="undefined"!=typeof window?window:Function("return this;")(),b=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:v,r=0;r max) { - value = max; - } else if (value < min) { - value = min; + var parsedValue = typeof value === 'string' ? parseFloat(value) : value; + if (parsedValue > max) { + parsedValue = max; + } else if (parsedValue < min) { + parsedValue = min; } - return value; + return parsedValue; } - function identity$1() { + function identity() { return [ 1, 0, @@ -836,14 +689,16 @@ var imagetools = (function () { 10 ]; function multiply(matrix1, matrix2) { - var i, j, k, val, col = [], out = new Array(10); - for (i = 0; i < 5; i++) { - for (j = 0; j < 5; j++) { + var col = []; + var out = new Array(25); + var val; + for (var i = 0; i < 5; i++) { + for (var j = 0; j < 5; j++) { col[j] = matrix2[j + i * 5]; } - for (j = 0; j < 5; j++) { + for (var j = 0; j < 5; j++) { val = 0; - for (k = 0; k < 5; k++) { + for (var k = 0; k < 5; k++) { val += matrix1[j + k * 5] * col[k]; } out[j + i * 5] = val; @@ -906,12 +761,11 @@ var imagetools = (function () { ]); } function adjustSaturation(matrix, value) { - var x, lumR, lumG, lumB; value = clamp(value, -1, 1); - x = 1 + (value > 0 ? 3 * value : value); - lumR = 0.3086; - lumG = 0.6094; - lumB = 0.082; + var x = 1 + (value > 0 ? 3 * value : value); + var lumR = 0.3086; + var lumG = 0.6094; + var lumB = 0.082; return multiply(matrix, [ lumR * (1 - x) + x, lumG * (1 - x), @@ -941,13 +795,12 @@ var imagetools = (function () { ]); } function adjustHue(matrix, angle) { - var cosVal, sinVal, lumR, lumG, lumB; angle = clamp(angle, -180, 180) / 180 * Math.PI; - cosVal = Math.cos(angle); - sinVal = Math.sin(angle); - lumR = 0.213; - lumG = 0.715; - lumB = 0.072; + var cosVal = Math.cos(angle); + var sinVal = Math.sin(angle); + var lumR = 0.213; + var lumG = 0.715; + var lumB = 0.072; return multiply(matrix, [ lumR + cosVal * (1 - lumR) + sinVal * -lumR, lumG + cosVal * -lumG + sinVal * -lumG, @@ -1098,18 +951,6 @@ var imagetools = (function () { 1 ], value)); } - var ColorMatrix = { - identity: identity$1, - adjust: adjust, - multiply: multiply, - adjustContrast: adjustContrast, - adjustBrightness: adjustBrightness, - adjustSaturation: adjustSaturation, - adjustHue: adjustHue, - adjustColors: adjustColors, - adjustSepia: adjustSepia, - adjustGrayscale: adjustGrayscale - }; function colorFilter(ir, matrix) { return ir.toCanvas().then(function (canvas) { @@ -1117,25 +958,25 @@ var imagetools = (function () { }); } function applyColorFilter(canvas, type, matrix) { - var context = Canvas.get2dContext(canvas); - var pixels; - function applyMatrix(pixels, m) { - var d = pixels.data, r, g, b, a, i, m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3], m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7], m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11], m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15], m16 = m[16], m17 = m[17], m18 = m[18], m19 = m[19]; - for (i = 0; i < d.length; i += 4) { - r = d[i]; - g = d[i + 1]; - b = d[i + 2]; - a = d[i + 3]; - d[i] = r * m0 + g * m1 + b * m2 + a * m3 + m4; - d[i + 1] = r * m5 + g * m6 + b * m7 + a * m8 + m9; - d[i + 2] = r * m10 + g * m11 + b * m12 + a * m13 + m14; - d[i + 3] = r * m15 + g * m16 + b * m17 + a * m18 + m19; - } - return pixels; - } - pixels = applyMatrix(context.getImageData(0, 0, canvas.width, canvas.height), matrix); + var context = get2dContext(canvas); + function applyMatrix(pixelsData, m) { + var r, g, b, a; + var data = pixelsData.data, m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3], m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7], m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11], m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15], m16 = m[16], m17 = m[17], m18 = m[18], m19 = m[19]; + for (var i = 0; i < data.length; i += 4) { + r = data[i]; + g = data[i + 1]; + b = data[i + 2]; + a = data[i + 3]; + data[i] = r * m0 + g * m1 + b * m2 + a * m3 + m4; + data[i + 1] = r * m5 + g * m6 + b * m7 + a * m8 + m9; + data[i + 2] = r * m10 + g * m11 + b * m12 + a * m13 + m14; + data[i + 3] = r * m15 + g * m16 + b * m17 + a * m18 + m19; + } + return pixelsData; + } + var pixels = applyMatrix(context.getImageData(0, 0, canvas.width, canvas.height), matrix); context.putImageData(pixels, 0, 0); - return ImageResult.fromCanvas(canvas, type); + return fromCanvas(canvas, type); } function convoluteFilter(ir, matrix) { return ir.toCanvas().then(function (canvas) { @@ -1143,10 +984,8 @@ var imagetools = (function () { }); } function applyConvoluteFilter(canvas, type, matrix) { - var context = Canvas.get2dContext(canvas); - var pixelsIn, pixelsOut; - function applyMatrix(pixelsIn, pixelsOut, matrix) { - var rgba, drgba, side, halfSide, x, y, r, g, b, cx, cy, scx, scy, offset, wt, w, h; + var context = get2dContext(canvas); + function applyMatrix(pIn, pOut, aMatrix) { function clamp(value, min, max) { if (value > max) { value = max; @@ -1155,59 +994,61 @@ var imagetools = (function () { } return value; } - side = Math.round(Math.sqrt(matrix.length)); - halfSide = Math.floor(side / 2); - rgba = pixelsIn.data; - drgba = pixelsOut.data; - w = pixelsIn.width; - h = pixelsIn.height; - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - r = g = b = 0; - for (cy = 0; cy < side; cy++) { - for (cx = 0; cx < side; cx++) { - scx = clamp(x + cx - halfSide, 0, w - 1); - scy = clamp(y + cy - halfSide, 0, h - 1); - offset = (scy * w + scx) * 4; - wt = matrix[cy * side + cx]; - r += rgba[offset] * wt; - g += rgba[offset + 1] * wt; - b += rgba[offset + 2] * wt; + var side = Math.round(Math.sqrt(aMatrix.length)); + var halfSide = Math.floor(side / 2); + var rgba = pIn.data; + var drgba = pOut.data; + var w = pIn.width; + var h = pIn.height; + for (var y = 0; y < h; y++) { + for (var x = 0; x < w; x++) { + var r = 0; + var g = 0; + var b = 0; + for (var cy = 0; cy < side; cy++) { + for (var cx = 0; cx < side; cx++) { + var scx = clamp(x + cx - halfSide, 0, w - 1); + var scy = clamp(y + cy - halfSide, 0, h - 1); + var innerOffset = (scy * w + scx) * 4; + var wt = aMatrix[cy * side + cx]; + r += rgba[innerOffset] * wt; + g += rgba[innerOffset + 1] * wt; + b += rgba[innerOffset + 2] * wt; } } - offset = (y * w + x) * 4; + var offset = (y * w + x) * 4; drgba[offset] = clamp(r, 0, 255); drgba[offset + 1] = clamp(g, 0, 255); drgba[offset + 2] = clamp(b, 0, 255); } } - return pixelsOut; + return pOut; } - pixelsIn = context.getImageData(0, 0, canvas.width, canvas.height); - pixelsOut = context.getImageData(0, 0, canvas.width, canvas.height); + var pixelsIn = context.getImageData(0, 0, canvas.width, canvas.height); + var pixelsOut = context.getImageData(0, 0, canvas.width, canvas.height); pixelsOut = applyMatrix(pixelsIn, pixelsOut, matrix); context.putImageData(pixelsOut, 0, 0); - return ImageResult.fromCanvas(canvas, type); + return fromCanvas(canvas, type); } function functionColorFilter(colorFn) { var filterImpl = function (canvas, type, value) { - var context = Canvas.get2dContext(canvas); - var pixels, i, lookup = new Array(256); - function applyLookup(pixels, lookup) { - var d = pixels.data, i; - for (i = 0; i < d.length; i += 4) { - d[i] = lookup[d[i]]; - d[i + 1] = lookup[d[i + 1]]; - d[i + 2] = lookup[d[i + 2]]; + var context = get2dContext(canvas); + var lookup = new Array(256); + function applyLookup(pixelsData, lookupData) { + var data = pixelsData.data; + for (var i = 0; i < data.length; i += 4) { + data[i] = lookupData[data[i]]; + data[i + 1] = lookupData[data[i + 1]]; + data[i + 2] = lookupData[data[i + 2]]; } - return pixels; + return pixelsData; } - for (i = 0; i < lookup.length; i++) { + for (var i = 0; i < lookup.length; i++) { lookup[i] = colorFn(i, value); } - pixels = applyLookup(context.getImageData(0, 0, canvas.width, canvas.height), lookup); + var pixels = applyLookup(context.getImageData(0, 0, canvas.width, canvas.height), lookup); context.putImageData(pixels, 0, 0); - return ImageResult.fromCanvas(canvas, type); + return fromCanvas(canvas, type); }; return function (ir, value) { return ir.toCanvas().then(function (canvas) { @@ -1217,7 +1058,7 @@ var imagetools = (function () { } function complexAdjustableColorFilter(matrixAdjustFn) { return function (ir, adjust) { - return colorFilter(ir, matrixAdjustFn(ColorMatrix.identity(), adjust)); + return colorFilter(ir, matrixAdjustFn(identity(), adjust)); }; } function basicColorFilter(matrix) { @@ -1230,73 +1071,74 @@ var imagetools = (function () { return convoluteFilter(ir, kernel); }; } - var Filters = { - invert: basicColorFilter([ - -1, - 0, - 0, - 0, - 255, - 0, - -1, - 0, - 0, - 255, - 0, - 0, - -1, - 0, - 255, - 0, - 0, - 0, - 1, - 0 - ]), - brightness: complexAdjustableColorFilter(ColorMatrix.adjustBrightness), - hue: complexAdjustableColorFilter(ColorMatrix.adjustHue), - saturate: complexAdjustableColorFilter(ColorMatrix.adjustSaturation), - contrast: complexAdjustableColorFilter(ColorMatrix.adjustContrast), - grayscale: complexAdjustableColorFilter(ColorMatrix.adjustGrayscale), - sepia: complexAdjustableColorFilter(ColorMatrix.adjustSepia), - colorize: function (ir, adjustR, adjustG, adjustB) { - return colorFilter(ir, ColorMatrix.adjustColors(ColorMatrix.identity(), adjustR, adjustG, adjustB)); - }, - sharpen: basicConvolutionFilter([ - 0, - -1, - 0, - -1, - 5, - -1, - 0, - -1, - 0 - ]), - emboss: basicConvolutionFilter([ - -2, - -1, - 0, - -1, - 1, - 1, - 0, - 1, - 2 - ]), - gamma: functionColorFilter(function (color, value) { - return Math.pow(color / 255, 1 - value) * 255; - }), - exposure: functionColorFilter(function (color, value) { - return 255 * (1 - Math.exp(-(color / 255) * value)); - }), - colorFilter: colorFilter, - convoluteFilter: convoluteFilter + var invert = basicColorFilter([ + -1, + 0, + 0, + 0, + 255, + 0, + -1, + 0, + 0, + 255, + 0, + 0, + -1, + 0, + 255, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 0, + 1 + ]); + var brightness = complexAdjustableColorFilter(adjustBrightness); + var hue = complexAdjustableColorFilter(adjustHue); + var saturate = complexAdjustableColorFilter(adjustSaturation); + var contrast = complexAdjustableColorFilter(adjustContrast); + var grayscale = complexAdjustableColorFilter(adjustGrayscale); + var sepia = complexAdjustableColorFilter(adjustSepia); + var colorize = function (ir, adjustR, adjustG, adjustB) { + return colorFilter(ir, adjustColors(identity(), adjustR, adjustG, adjustB)); }; + var sharpen = basicConvolutionFilter([ + 0, + -1, + 0, + -1, + 5, + -1, + 0, + -1, + 0 + ]); + var emboss = basicConvolutionFilter([ + -2, + -1, + 0, + -1, + 1, + 1, + 0, + 1, + 2 + ]); + var gamma = functionColorFilter(function (color, value) { + return Math.pow(color / 255, 1 - value) * 255; + }); + var exposure = functionColorFilter(function (color, value) { + return 255 * (1 - Math.exp(-(color / 255) * value)); + }); function scale(image, dW, dH) { - var sW = ImageSize.getWidth(image); - var sH = ImageSize.getHeight(image); + var sW = getWidth(image); + var sH = getHeight(image); var wRatio = dW / sW; var hRatio = dH / sH; var scaleCapped = false; @@ -1315,17 +1157,16 @@ var imagetools = (function () { } function _scale(image, wRatio, hRatio) { return new Promise(function (resolve) { - var sW = ImageSize.getWidth(image); - var sH = ImageSize.getHeight(image); + var sW = getWidth(image); + var sH = getHeight(image); var dW = Math.floor(sW * wRatio); var dH = Math.floor(sH * hRatio); - var canvas = Canvas.create(dW, dH); - var context = Canvas.get2dContext(canvas); + var canvas = create(dW, dH); + var context = get2dContext(canvas); context.drawImage(image, 0, 0, sW, sH, 0, 0, dW, dH); resolve(canvas); }); } - var ImageResizerCanvas = { scale: scale }; function rotate(ir, angle) { return ir.toCanvas().then(function (canvas) { @@ -1333,23 +1174,24 @@ var imagetools = (function () { }); } function applyRotate(image, type, angle) { - var canvas = Canvas.create(image.width, image.height); - var context = Canvas.get2dContext(canvas); - var translateX = 0, translateY = 0; + var canvas = create(image.width, image.height); + var context = get2dContext(canvas); + var translateX = 0; + var translateY = 0; angle = angle < 0 ? 360 + angle : angle; - if (angle == 90 || angle == 270) { - Canvas.resize(canvas, canvas.height, canvas.width); + if (angle === 90 || angle === 270) { + resize(canvas, canvas.height, canvas.width); } - if (angle == 90 || angle == 180) { + if (angle === 90 || angle === 180) { translateX = canvas.width; } - if (angle == 270 || angle == 180) { + if (angle === 270 || angle === 180) { translateY = canvas.height; } context.translate(translateX, translateY); context.rotate(angle * Math.PI / 180); context.drawImage(image, 0, 0); - return ImageResult.fromCanvas(canvas, type); + return fromCanvas(canvas, type); } function flip(ir, axis) { return ir.toCanvas().then(function (canvas) { @@ -1357,16 +1199,16 @@ var imagetools = (function () { }); } function applyFlip(image, type, axis) { - var canvas = Canvas.create(image.width, image.height); - var context = Canvas.get2dContext(canvas); - if (axis == 'v') { + var canvas = create(image.width, image.height); + var context = get2dContext(canvas); + if (axis === 'v') { context.scale(1, -1); context.drawImage(image, 0, -canvas.height); } else { context.scale(-1, 1); context.drawImage(image, -canvas.width, 0); } - return ImageResult.fromCanvas(canvas, type); + return fromCanvas(canvas, type); } function crop(ir, x, y, w, h) { return ir.toCanvas().then(function (canvas) { @@ -1374,598 +1216,97 @@ var imagetools = (function () { }); } function applyCrop(image, type, x, y, w, h) { - var canvas = Canvas.create(w, h); - var context = Canvas.get2dContext(canvas); + var canvas = create(w, h); + var context = get2dContext(canvas); context.drawImage(image, -x, -y); - return ImageResult.fromCanvas(canvas, type); + return fromCanvas(canvas, type); } function resize$1(ir, w, h) { return ir.toCanvas().then(function (canvas) { - return ImageResizerCanvas.scale(canvas, w, h).then(function (newCanvas) { - return ImageResult.fromCanvas(newCanvas, ir.getType()); + return scale(canvas, w, h).then(function (newCanvas) { + return fromCanvas(newCanvas, ir.getType()); }); }); } - var ImageTools = { - rotate: rotate, - flip: flip, - crop: crop, - resize: resize$1 - }; - - var BinaryReader = function () { - function BinaryReader(ar) { - this.littleEndian = false; - this._dv = new DataView(ar); - } - BinaryReader.prototype.readByteAt = function (idx) { - return this._dv.getUint8(idx); - }; - BinaryReader.prototype.read = function (idx, size) { - if (idx + size > this.length()) { - return null; - } - var mv = this.littleEndian ? 0 : -8 * (size - 1); - for (var i = 0, sum = 0; i < size; i++) { - sum |= this.readByteAt(idx + i) << Math.abs(mv + i * 8); - } - return sum; - }; - BinaryReader.prototype.BYTE = function (idx) { - return this.read(idx, 1); - }; - BinaryReader.prototype.SHORT = function (idx) { - return this.read(idx, 2); - }; - BinaryReader.prototype.LONG = function (idx) { - return this.read(idx, 4); - }; - BinaryReader.prototype.SLONG = function (idx) { - var num = this.read(idx, 4); - return num > 2147483647 ? num - 4294967296 : num; - }; - BinaryReader.prototype.CHAR = function (idx) { - return String.fromCharCode(this.read(idx, 1)); - }; - BinaryReader.prototype.STRING = function (idx, count) { - return this.asArray('CHAR', idx, count).join(''); - }; - BinaryReader.prototype.SEGMENT = function (idx, size) { - var ar = this._dv.buffer; - switch (arguments.length) { - case 2: - return ar.slice(idx, idx + size); - case 1: - return ar.slice(idx); - default: - return ar; - } - }; - BinaryReader.prototype.asArray = function (type, idx, count) { - var values = []; - for (var i = 0; i < count; i++) { - values[i] = this[type](idx + i); - } - return values; - }; - BinaryReader.prototype.length = function () { - return this._dv ? this._dv.byteLength : 0; - }; - return BinaryReader; - }(); - var tags = { - tiff: { - 274: 'Orientation', - 270: 'ImageDescription', - 271: 'Make', - 272: 'Model', - 305: 'Software', - 34665: 'ExifIFDPointer', - 34853: 'GPSInfoIFDPointer' - }, - exif: { - 36864: 'ExifVersion', - 40961: 'ColorSpace', - 40962: 'PixelXDimension', - 40963: 'PixelYDimension', - 36867: 'DateTimeOriginal', - 33434: 'ExposureTime', - 33437: 'FNumber', - 34855: 'ISOSpeedRatings', - 37377: 'ShutterSpeedValue', - 37378: 'ApertureValue', - 37383: 'MeteringMode', - 37384: 'LightSource', - 37385: 'Flash', - 37386: 'FocalLength', - 41986: 'ExposureMode', - 41987: 'WhiteBalance', - 41990: 'SceneCaptureType', - 41988: 'DigitalZoomRatio', - 41992: 'Contrast', - 41993: 'Saturation', - 41994: 'Sharpness' - }, - gps: { - 0: 'GPSVersionID', - 1: 'GPSLatitudeRef', - 2: 'GPSLatitude', - 3: 'GPSLongitudeRef', - 4: 'GPSLongitude' - }, - thumb: { - 513: 'JPEGInterchangeFormat', - 514: 'JPEGInterchangeFormatLength' - } + var invert$1 = function (ir) { + return invert(ir); }; - var tagDescs = { - 'ColorSpace': { - 1: 'sRGB', - 0: 'Uncalibrated' - }, - 'MeteringMode': { - 0: 'Unknown', - 1: 'Average', - 2: 'CenterWeightedAverage', - 3: 'Spot', - 4: 'MultiSpot', - 5: 'Pattern', - 6: 'Partial', - 255: 'Other' - }, - 'LightSource': { - 1: 'Daylight', - 2: 'Fliorescent', - 3: 'Tungsten', - 4: 'Flash', - 9: 'Fine weather', - 10: 'Cloudy weather', - 11: 'Shade', - 12: 'Daylight fluorescent (D 5700 - 7100K)', - 13: 'Day white fluorescent (N 4600 -5400K)', - 14: 'Cool white fluorescent (W 3900 - 4500K)', - 15: 'White fluorescent (WW 3200 - 3700K)', - 17: 'Standard light A', - 18: 'Standard light B', - 19: 'Standard light C', - 20: 'D55', - 21: 'D65', - 22: 'D75', - 23: 'D50', - 24: 'ISO studio tungsten', - 255: 'Other' - }, - 'Flash': { - 0: 'Flash did not fire', - 1: 'Flash fired', - 5: 'Strobe return light not detected', - 7: 'Strobe return light detected', - 9: 'Flash fired, compulsory flash mode', - 13: 'Flash fired, compulsory flash mode, return light not detected', - 15: 'Flash fired, compulsory flash mode, return light detected', - 16: 'Flash did not fire, compulsory flash mode', - 24: 'Flash did not fire, auto mode', - 25: 'Flash fired, auto mode', - 29: 'Flash fired, auto mode, return light not detected', - 31: 'Flash fired, auto mode, return light detected', - 32: 'No flash function', - 65: 'Flash fired, red-eye reduction mode', - 69: 'Flash fired, red-eye reduction mode, return light not detected', - 71: 'Flash fired, red-eye reduction mode, return light detected', - 73: 'Flash fired, compulsory flash mode, red-eye reduction mode', - 77: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected', - 79: 'Flash fired, compulsory flash mode, red-eye reduction mode, return light detected', - 89: 'Flash fired, auto mode, red-eye reduction mode', - 93: 'Flash fired, auto mode, return light not detected, red-eye reduction mode', - 95: 'Flash fired, auto mode, return light detected, red-eye reduction mode' - }, - 'ExposureMode': { - 0: 'Auto exposure', - 1: 'Manual exposure', - 2: 'Auto bracket' - }, - 'WhiteBalance': { - 0: 'Auto white balance', - 1: 'Manual white balance' - }, - 'SceneCaptureType': { - 0: 'Standard', - 1: 'Landscape', - 2: 'Portrait', - 3: 'Night scene' - }, - 'Contrast': { - 0: 'Normal', - 1: 'Soft', - 2: 'Hard' - }, - 'Saturation': { - 0: 'Normal', - 1: 'Low saturation', - 2: 'High saturation' - }, - 'Sharpness': { - 0: 'Normal', - 1: 'Soft', - 2: 'Hard' - }, - 'GPSLatitudeRef': { - N: 'North latitude', - S: 'South latitude' - }, - 'GPSLongitudeRef': { - E: 'East longitude', - W: 'West longitude' - } - }; - var ExifReader = function () { - function ExifReader(ar) { - this._offsets = { - tiffHeader: 10, - IFD0: null, - IFD1: null, - exifIFD: null, - gpsIFD: null - }; - this._tiffTags = {}; - var self = this; - self._reader = new BinaryReader(ar); - self._idx = self._offsets.tiffHeader; - if (self.SHORT(0) !== 65505 || self.STRING(4, 5).toUpperCase() !== 'EXIF\0') { - throw new Error('Exif data cannot be read or not available.'); - } - self._reader.littleEndian = self.SHORT(self._idx) == 18761; - if (self.SHORT(self._idx += 2) !== 42) { - throw new Error('Invalid Exif data.'); - } - self._offsets.IFD0 = self._offsets.tiffHeader + self.LONG(self._idx += 2); - self._tiffTags = self.extractTags(self._offsets.IFD0, tags.tiff); - if ('ExifIFDPointer' in self._tiffTags) { - self._offsets.exifIFD = self._offsets.tiffHeader + self._tiffTags.ExifIFDPointer; - delete self._tiffTags.ExifIFDPointer; - } - if ('GPSInfoIFDPointer' in self._tiffTags) { - self._offsets.gpsIFD = self._offsets.tiffHeader + self._tiffTags.GPSInfoIFDPointer; - delete self._tiffTags.GPSInfoIFDPointer; - } - var IFD1Offset = self.LONG(self._offsets.IFD0 + self.SHORT(self._offsets.IFD0) * 12 + 2); - if (IFD1Offset) { - self._offsets.IFD1 = self._offsets.tiffHeader + IFD1Offset; - } - } - ExifReader.prototype.BYTE = function (idx) { - return this._reader.BYTE(idx); - }; - ExifReader.prototype.SHORT = function (idx) { - return this._reader.SHORT(idx); - }; - ExifReader.prototype.LONG = function (idx) { - return this._reader.LONG(idx); - }; - ExifReader.prototype.SLONG = function (idx) { - return this._reader.SLONG(idx); - }; - ExifReader.prototype.CHAR = function (idx) { - return this._reader.CHAR(idx); - }; - ExifReader.prototype.STRING = function (idx, count) { - return this._reader.STRING(idx, count); - }; - ExifReader.prototype.SEGMENT = function (idx, size) { - return this._reader.SEGMENT(idx, size); - }; - ExifReader.prototype.asArray = function (type, idx, count) { - var values = []; - for (var i = 0; i < count; i++) { - values[i] = this[type](idx + i); - } - return values; - }; - ExifReader.prototype.length = function () { - return this._reader.length(); - }; - ExifReader.prototype.UNDEFINED = function () { - return this.BYTE.apply(this, arguments); - }; - ExifReader.prototype.RATIONAL = function (idx) { - return this.LONG(idx) / this.LONG(idx + 4); - }; - ExifReader.prototype.SRATIONAL = function (idx) { - return this.SLONG(idx) / this.SLONG(idx + 4); - }; - ExifReader.prototype.ASCII = function (idx) { - return this.CHAR(idx); - }; - ExifReader.prototype.TIFF = function () { - return this._tiffTags; - }; - ExifReader.prototype.EXIF = function () { - var self = this; - var Exif = null; - if (self._offsets.exifIFD) { - try { - Exif = self.extractTags(self._offsets.exifIFD, tags.exif); - } catch (ex) { - return null; - } - if (Exif.ExifVersion && Array.isArray(Exif.ExifVersion)) { - for (var i = 0, exifVersion = ''; i < Exif.ExifVersion.length; i++) { - exifVersion += String.fromCharCode(Exif.ExifVersion[i]); - } - Exif.ExifVersion = exifVersion; - } - } - return Exif; - }; - ExifReader.prototype.GPS = function () { - var self = this; - var GPS = null; - if (self._offsets.gpsIFD) { - try { - GPS = self.extractTags(self._offsets.gpsIFD, tags.gps); - } catch (ex) { - return null; - } - if (GPS.GPSVersionID && Array.isArray(GPS.GPSVersionID)) { - GPS.GPSVersionID = GPS.GPSVersionID.join('.'); - } - } - return GPS; - }; - ExifReader.prototype.thumb = function () { - var self = this; - if (self._offsets.IFD1) { - try { - var IFD1Tags = self.extractTags(self._offsets.IFD1, tags.thumb); - if ('JPEGInterchangeFormat' in IFD1Tags) { - return self.SEGMENT(self._offsets.tiffHeader + IFD1Tags.JPEGInterchangeFormat, IFD1Tags.JPEGInterchangeFormatLength); - } - } catch (ex) { - } - } - return null; - }; - ExifReader.prototype.extractTags = function (IFD_offset, tags2extract) { - var self = this; - var length, i, tag, type, count, size, offset, value, values = [], hash = {}; - var types = { - 1: 'BYTE', - 7: 'UNDEFINED', - 2: 'ASCII', - 3: 'SHORT', - 4: 'LONG', - 5: 'RATIONAL', - 9: 'SLONG', - 10: 'SRATIONAL' - }; - var sizes = { - 'BYTE': 1, - 'UNDEFINED': 1, - 'ASCII': 1, - 'SHORT': 2, - 'LONG': 4, - 'RATIONAL': 8, - 'SLONG': 4, - 'SRATIONAL': 8 - }; - length = self.SHORT(IFD_offset); - for (i = 0; i < length; i++) { - values = []; - offset = IFD_offset + 2 + i * 12; - tag = tags2extract[self.SHORT(offset)]; - if (tag === undefined) { - continue; - } - type = types[self.SHORT(offset += 2)]; - count = self.LONG(offset += 2); - size = sizes[type]; - if (!size) { - throw new Error('Invalid Exif data.'); - } - offset += 4; - if (size * count > 4) { - offset = self.LONG(offset) + self._offsets.tiffHeader; - } - if (offset + size * count >= self.length()) { - throw new Error('Invalid Exif data.'); - } - if (type === 'ASCII') { - hash[tag] = self.STRING(offset, count).replace(/\0$/, '').trim(); - continue; - } else { - values = self.asArray(type, offset, count); - value = count == 1 ? values[0] : values; - if (tagDescs.hasOwnProperty(tag) && typeof value != 'object') { - hash[tag] = tagDescs[tag][value]; - } else { - hash[tag] = value; - } - } - } - return hash; - }; - return ExifReader; - }(); - - var extractFrom = function (blob) { - return Conversions.blobToArrayBuffer(blob).then(function (ar) { - try { - var br = new BinaryReader(ar); - if (br.SHORT(0) === 65496) { - var headers = extractHeaders(br); - var app1 = headers.filter(function (header) { - return header.name === 'APP1'; - }); - var meta = {}; - if (app1.length) { - var exifReader = new ExifReader(app1[0].segment); - meta = { - tiff: exifReader.TIFF(), - exif: exifReader.EXIF(), - gps: exifReader.GPS(), - thumb: exifReader.thumb() - }; - } else { - return Promise.reject('Headers did not include required information'); - } - meta.rawHeaders = headers; - return meta; - } - return Promise.reject('Image was not a jpeg'); - } catch (ex) { - return Promise.reject('Unsupported format or not an image: ' + blob.type + ' (Exception: ' + ex.message + ')'); - } - }); - }; - var extractHeaders = function (br) { - var headers = [], idx, marker, length = 0; - idx = 2; - while (idx <= br.length()) { - marker = br.SHORT(idx); - if (marker >= 65488 && marker <= 65495) { - idx += 2; - continue; - } - if (marker === 65498 || marker === 65497) { - break; - } - length = br.SHORT(idx + 2) + 2; - if (marker >= 65505 && marker <= 65519) { - headers.push({ - hex: marker, - name: 'APP' + (marker & 15), - start: idx, - length: length, - segment: br.SEGMENT(idx, length) - }); - } - idx += length; - } - return headers; - }; - var JPEGMeta = { extractFrom: extractFrom }; - - var invert = function (ir) { - return Filters.invert(ir); - }; - var sharpen = function (ir) { - return Filters.sharpen(ir); + var sharpen$1 = function (ir) { + return sharpen(ir); }; - var emboss = function (ir) { - return Filters.emboss(ir); + var emboss$1 = function (ir) { + return emboss(ir); }; - var gamma = function (ir, value) { - return Filters.gamma(ir, value); + var gamma$1 = function (ir, value) { + return gamma(ir, value); }; - var exposure = function (ir, value) { - return Filters.exposure(ir, value); + var exposure$1 = function (ir, value) { + return exposure(ir, value); }; - var colorize = function (ir, adjustR, adjustG, adjustB) { - return Filters.colorize(ir, adjustR, adjustG, adjustB); + var colorize$1 = function (ir, adjustR, adjustG, adjustB) { + return colorize(ir, adjustR, adjustG, adjustB); }; - var brightness = function (ir, adjust) { - return Filters.brightness(ir, adjust); + var brightness$1 = function (ir, adjust) { + return brightness(ir, adjust); }; - var hue = function (ir, adjust) { - return Filters.hue(ir, adjust); + var hue$1 = function (ir, adjust) { + return hue(ir, adjust); }; - var saturate = function (ir, adjust) { - return Filters.saturate(ir, adjust); + var saturate$1 = function (ir, adjust) { + return saturate(ir, adjust); }; - var contrast = function (ir, adjust) { - return Filters.contrast(ir, adjust); + var contrast$1 = function (ir, adjust) { + return contrast(ir, adjust); }; - var grayscale = function (ir, adjust) { - return Filters.grayscale(ir, adjust); + var grayscale$1 = function (ir, adjust) { + return grayscale(ir, adjust); }; - var sepia = function (ir, adjust) { - return Filters.sepia(ir, adjust); + var sepia$1 = function (ir, adjust) { + return sepia(ir, adjust); }; var flip$1 = function (ir, axis) { - return ImageTools.flip(ir, axis); + return flip(ir, axis); }; var crop$1 = function (ir, x, y, w, h) { - return ImageTools.crop(ir, x, y, w, h); + return crop(ir, x, y, w, h); }; var resize$2 = function (ir, w, h) { - return ImageTools.resize(ir, w, h); + return resize$1(ir, w, h); }; var rotate$1 = function (ir, angle) { - return ImageTools.rotate(ir, angle); - }; - var exifRotate = function (ir) { - var ROTATE_90 = 6; - var ROTATE_180 = 3; - var ROTATE_270 = 8; - var checkRotation = function (data) { - var orientation = data.tiff.Orientation; - switch (orientation) { - case ROTATE_90: - return rotate$1(ir, 90); - case ROTATE_180: - return rotate$1(ir, 180); - case ROTATE_270: - return rotate$1(ir, 270); - default: - return ir; - } - }; - var notJpeg = function () { - return ir; - }; - return ir.toBlob().then(JPEGMeta.extractFrom).then(checkRotation, notJpeg); - }; - var ImageTransformations = { - invert: invert, - sharpen: sharpen, - emboss: emboss, - brightness: brightness, - hue: hue, - saturate: saturate, - contrast: contrast, - grayscale: grayscale, - sepia: sepia, - colorize: colorize, - gamma: gamma, - exposure: exposure, - flip: flip$1, - crop: crop$1, - resize: resize$2, - rotate: rotate$1, - exifRotate: exifRotate + return rotate(ir, angle); }; var blobToImageResult = function (blob) { - return ImageResult.fromBlob(blob); - }; - var fromBlobAndUrlSync$1 = function (blob, uri) { - return ImageResult.fromBlobAndUrlSync(blob, uri); - }; - var imageToImageResult = function (image) { - return ImageResult.fromImage(image); + return fromBlob(blob); }; - var imageResultToBlob = function (ir, type, quality) { - if (type === undefined && quality === undefined) { - return imageResultToOriginalBlob(ir); - } else { - return ir.toAdjustedBlob(type, quality); + + 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 imageResultToOriginalBlob = function (ir) { - return ir.toBlob(); + var resolve = function (p, scope) { + var parts = p.split('.'); + return path(parts, scope); }; - var imageResultToDataURL = function (ir) { - return ir.toDataURL(); + + var unsafe = function (name, scope) { + return resolve(name, scope); }; - var ResultConversions = { - blobToImageResult: blobToImageResult, - fromBlobAndUrlSync: fromBlobAndUrlSync$1, - imageToImageResult: imageToImageResult, - imageResultToBlob: imageResultToBlob, - imageResultToOriginalBlob: imageResultToOriginalBlob, - imageResultToDataURL: imageResultToDataURL + 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 url = function () { return Global$1.getOrDie('URL'); @@ -1976,7 +1317,7 @@ var imagetools = (function () { var revokeObjectURL = function (u) { url().revokeObjectURL(u); }; - var URL$1 = { + var URL = { createObjectURL: createObjectURL, revokeObjectURL: revokeObjectURL }; @@ -2053,7 +1394,7 @@ var imagetools = (function () { var global$7 = tinymce.util.Tools.resolve('tinymce.geom.Rect'); - var loadImage$1 = function (image) { + var loadImage = function (image) { return new global$3(function (resolve) { var loaded = function () { image.removeEventListener('load', loaded); @@ -2066,7 +1407,7 @@ var imagetools = (function () { } }); }; - var LoadImage = { loadImage: loadImage$1 }; + var LoadImage = { loadImage: loadImage }; var global$8 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery'); @@ -2362,19 +1703,19 @@ var imagetools = (function () { this.state.set('cropEnabled', state); }, imageSrc: function (url) { - var self$$1 = this, img = new Image(); + var self = this, img = new domGlobals.Image(); img.src = url; LoadImage.loadImage(img).then(function () { var rect, $img; - var lastRect = self$$1.state.get('viewRect'); - $img = self$$1.$el.find('img'); + var lastRect = self.state.get('viewRect'); + $img = self.$el.find('img'); if ($img[0]) { $img.replaceWith(img); } else { - var bg = document.createElement('div'); + var bg = domGlobals.document.createElement('div'); bg.className = 'mce-imagepanel-bg'; - self$$1.getEl().appendChild(bg); - self$$1.getEl().appendChild(img); + self.getEl().appendChild(bg); + self.getEl().appendChild(img); } rect = { x: 0, @@ -2382,13 +1723,13 @@ var imagetools = (function () { w: img.naturalWidth, h: img.naturalHeight }; - self$$1.state.set('viewRect', rect); - self$$1.state.set('rect', global$7.inflate(rect, -20, -20)); + self.state.set('viewRect', rect); + self.state.set('rect', global$7.inflate(rect, -20, -20)); if (!lastRect || lastRect.w !== rect.w || lastRect.h !== rect.h) { - self$$1.zoomFit(); + self.zoomFit(); } - self$$1.repaintImage(); - self$$1.fire('load'); + self.repaintImage(); + self.fire('load'); }); }, zoom: function (value) { @@ -2403,19 +1744,19 @@ var imagetools = (function () { return this._super(); }, zoomFit: function () { - var self$$1 = this; + var self = this; var $img, pw, ph, w, h, zoom, padding; padding = 10; - $img = self$$1.$el.find('img'); - pw = self$$1.getEl().clientWidth; - ph = self$$1.getEl().clientHeight; + $img = self.$el.find('img'); + pw = self.getEl().clientWidth; + ph = self.getEl().clientHeight; w = $img[0].naturalWidth; h = $img[0].naturalHeight; zoom = Math.min((pw - padding) / w, (ph - padding) / h); if (zoom >= 1) { zoom = 1; } - self$$1.zoom(zoom); + self.zoom(zoom); }, repaintImage: function () { var x, y, w, h, pw, ph, $img, $bg, zoom, rect, elm; @@ -2464,37 +1805,37 @@ var imagetools = (function () { } }, bindStates: function () { - var self$$1 = this; + var self = this; function setupCropRect(rect) { - self$$1.cropRect = CropRect(rect, self$$1.state.get('viewRect'), self$$1.state.get('viewRect'), self$$1.getEl(), function () { - self$$1.fire('crop'); + self.cropRect = CropRect(rect, self.state.get('viewRect'), self.state.get('viewRect'), self.getEl(), function () { + self.fire('crop'); }); - self$$1.cropRect.on('updateRect', function (e) { + self.cropRect.on('updateRect', function (e) { var rect = e.rect; - var zoom = self$$1.zoom(); + var zoom = self.zoom(); rect = { x: Math.round(rect.x / zoom), y: Math.round(rect.y / zoom), w: Math.round(rect.w / zoom), h: Math.round(rect.h / zoom) }; - self$$1.state.set('rect', rect); + self.state.set('rect', rect); }); - self$$1.on('remove', self$$1.cropRect.destroy); + self.on('remove', self.cropRect.destroy); } - self$$1.state.on('change:cropEnabled', function (e) { - self$$1.cropRect.toggleVisibility(e.value); - self$$1.repaintImage(); + self.state.on('change:cropEnabled', function (e) { + self.cropRect.toggleVisibility(e.value); + self.repaintImage(); }); - self$$1.state.on('change:zoom', function () { - self$$1.repaintImage(); + self.state.on('change:zoom', function () { + self.repaintImage(); }); - self$$1.state.on('change:rect', function (e) { + self.state.on('change:rect', function (e) { var rect = e.value; - if (!self$$1.cropRect) { + if (!self.cropRect) { setupCropRect(rect); } - self$$1.cropRect.setRect(rect); + self.cropRect.setRect(rect); }); } }); @@ -2505,12 +1846,12 @@ var imagetools = (function () { function createState(blob) { return { blob: blob, - url: URL$1.createObjectURL(blob) + url: URL.createObjectURL(blob) }; } function destroyState(state) { if (state) { - URL$1.revokeObjectURL(state.url); + URL.revokeObjectURL(state.url); } } function destroyStates(states) { @@ -2580,8 +1921,8 @@ var imagetools = (function () { } function crop() { var rect = imagePanel.selection(); - ResultConversions.blobToImageResult(currentState.blob).then(function (ir) { - ImageTransformations.crop(ir, rect.x, rect.y, rect.w, rect.h).then(imageResultToBlob).then(function (blob) { + blobToImageResult(currentState.blob).then(function (ir) { + crop$1(ir, rect.x, rect.y, rect.w, rect.h).then(imageResultToBlob).then(function (blob) { addBlobState(blob); cancel(); }); @@ -2591,7 +1932,7 @@ var imagetools = (function () { var args = [].slice.call(arguments, 1); return function () { var state = tempState || currentState; - ResultConversions.blobToImageResult(state.blob).then(function (ir) { + blobToImageResult(state.blob).then(function (ir) { fn.apply(this, [ir].concat(args)).then(imageResultToBlob).then(addTempState); }); }; @@ -2603,7 +1944,7 @@ var imagetools = (function () { } var args = [].slice.call(arguments, 1); return function () { - ResultConversions.blobToImageResult(currentState.blob).then(function (ir) { + blobToImageResult(currentState.blob).then(function (ir) { fn.apply(this, [ir].concat(args)).then(imageResultToBlob).then(addBlobState); }); }; @@ -2702,7 +2043,7 @@ var imagetools = (function () { } ])).hide().on('show', function () { disableUndoRedo(); - ResultConversions.blobToImageResult(currentState.blob).then(function (ir) { + blobToImageResult(currentState.blob).then(function (ir) { return filter(ir); }).then(imageResultToBlob).then(function (blob) { var newTempState = createState(blob); @@ -2714,7 +2055,7 @@ var imagetools = (function () { } function createVariableFilterPanel(title, filter, value, min, max) { function update(value) { - ResultConversions.blobToImageResult(currentState.blob).then(function (ir) { + blobToImageResult(currentState.blob).then(function (ir) { return filter(ir, value); }).then(imageResultToBlob).then(function (blob) { var newTempState = createState(blob); @@ -2763,7 +2104,7 @@ var imagetools = (function () { r = win.find('#r')[0].value(); g = win.find('#g')[0].value(); b = win.find('#b')[0].value(); - ResultConversions.blobToImageResult(currentState.blob).then(function (ir) { + blobToImageResult(currentState.blob).then(function (ir) { return filter(ir, r, g, b); }).then(imageResultToBlob).then(function (blob) { var newTempState = createState(blob); @@ -2892,7 +2233,7 @@ var imagetools = (function () { ])).hide().on('submit', function (e) { var width = parseInt(win.find('#w').value(), 10), height = parseInt(win.find('#h').value(), 10); e.preventDefault(); - action(ImageTransformations.resize, width, height)(); + action(resize$2, width, height)(); cancel(); }).on('show', disableUndoRedo); flipRotatePanel = createPanel(reverseIfRtl([ @@ -2907,22 +2248,22 @@ var imagetools = (function () { { icon: 'fliph', tooltip: 'Flip horizontally', - onclick: tempAction(ImageTransformations.flip, 'h') + onclick: tempAction(flip$1, 'h') }, { icon: 'flipv', tooltip: 'Flip vertically', - onclick: tempAction(ImageTransformations.flip, 'v') + onclick: tempAction(flip$1, 'v') }, { icon: 'rotateleft', tooltip: 'Rotate counterclockwise', - onclick: tempAction(ImageTransformations.rotate, -90) + onclick: tempAction(rotate$1, -90) }, { icon: 'rotateright', tooltip: 'Rotate clockwise', - onclick: tempAction(ImageTransformations.rotate, 90) + onclick: tempAction(rotate$1, 90) }, { type: 'spacer', @@ -2934,18 +2275,18 @@ var imagetools = (function () { onclick: applyTempState } ])).hide().on('show', disableUndoRedo); - invertPanel = createFilterPanel('Invert', ImageTransformations.invert); - sharpenPanel = createFilterPanel('Sharpen', ImageTransformations.sharpen); - embossPanel = createFilterPanel('Emboss', ImageTransformations.emboss); - brightnessPanel = createVariableFilterPanel('Brightness', ImageTransformations.brightness, 0, -1, 1); - huePanel = createVariableFilterPanel('Hue', ImageTransformations.hue, 180, 0, 360); - saturatePanel = createVariableFilterPanel('Saturate', ImageTransformations.saturate, 0, -1, 1); - contrastPanel = createVariableFilterPanel('Contrast', ImageTransformations.contrast, 0, -1, 1); - grayscalePanel = createVariableFilterPanel('Grayscale', ImageTransformations.grayscale, 0, 0, 1); - sepiaPanel = createVariableFilterPanel('Sepia', ImageTransformations.sepia, 0, 0, 1); - colorizePanel = createRgbFilterPanel('Colorize', ImageTransformations.colorize); - gammaPanel = createVariableFilterPanel('Gamma', ImageTransformations.gamma, 0, -1, 1); - exposurePanel = createVariableFilterPanel('Exposure', ImageTransformations.exposure, 1, 0, 2); + invertPanel = createFilterPanel('Invert', invert$1); + sharpenPanel = createFilterPanel('Sharpen', sharpen$1); + embossPanel = createFilterPanel('Emboss', emboss$1); + brightnessPanel = createVariableFilterPanel('Brightness', brightness$1, 0, -1, 1); + huePanel = createVariableFilterPanel('Hue', hue$1, 180, 0, 360); + saturatePanel = createVariableFilterPanel('Saturate', saturate$1, 0, -1, 1); + contrastPanel = createVariableFilterPanel('Contrast', contrast$1, 0, -1, 1); + grayscalePanel = createVariableFilterPanel('Grayscale', grayscale$1, 0, 0, 1); + sepiaPanel = createVariableFilterPanel('Sepia', sepia$1, 0, 0, 1); + colorizePanel = createRgbFilterPanel('Colorize', colorize$1); + gammaPanel = createVariableFilterPanel('Gamma', gamma$1, 0, -1, 1); + exposurePanel = createVariableFilterPanel('Exposure', exposure$1, 1, 0, 2); filtersPanel = createPanel(reverseIfRtl([ { text: 'Back', @@ -3200,20 +2541,23 @@ var imagetools = (function () { h: img.naturalHeight }; } - var ImageSize$1 = { + var ImageSize = { getImageSize: getImageSize, setImageSize: setImageSize, getNaturalImageSize: getNaturalImageSize }; var typeOf = function (x) { - if (x === null) + if (x === null) { return 'null'; + } var t = typeof x; - if (t === 'object' && Array.prototype.isPrototypeOf(x)) + if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) { return 'array'; - if (t === 'object' && String.prototype.isPrototypeOf(x)) + } + if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) { return 'string'; + } return t; }; var isType = function (type) { @@ -3223,21 +2567,26 @@ var imagetools = (function () { }; var isFunction = isType('function'); + var nativeSlice = Array.prototype.slice; var find = function (xs, pred) { for (var i = 0, len = xs.length; i < len; i++) { var x = xs[i]; - if (pred(x, i, xs)) { + if (pred(x, i)) { return Option.some(x); } } return Option.none(); }; - var slice = Array.prototype.slice; var from$1 = isFunction(Array.from) ? Array.from : function (x) { - return slice.call(x); + return nativeSlice.call(x); }; - function XMLHttpRequest$1 () { + function FileReader () { + var f = Global$1.getOrDie('FileReader'); + return new f(); + } + + function XMLHttpRequest () { var f = Global$1.getOrDie('XMLHttpRequest'); return new f(); } @@ -3255,7 +2604,7 @@ var imagetools = (function () { var requestUrlAsBlob = function (url, headers, withCredentials) { return new global$3(function (resolve) { var xhr; - xhr = XMLHttpRequest$1(); + xhr = XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { resolve({ @@ -3445,7 +2794,7 @@ var imagetools = (function () { apiKey = getApiKey(editor); return Proxy.getUrl(src, apiKey, false); } - return BlobConversions.imageToBlob(img); + return imageToBlob$1(img); }; var findSelectedBlob = function (editor) { var blobInfo; @@ -3512,7 +2861,7 @@ var imagetools = (function () { }; var selectedImageOperation = function (editor, imageUploadTimerState, fn, size) { return function () { - return editor._scanForImages().then(curry(findSelectedBlob, editor)).then(ResultConversions.blobToImageResult).then(fn).then(function (imageResult) { + return editor._scanForImages().then(curry(findSelectedBlob, editor)).then(blobToImageResult).then(fn).then(function (imageResult) { return updateSelectedImage(editor, imageResult, false, imageUploadTimerState, size); }, function (error) { displayError(editor, error); @@ -3521,47 +2870,47 @@ var imagetools = (function () { }; var rotate$2 = function (editor, imageUploadTimerState, angle) { return function () { - var size = ImageSize$1.getImageSize(getSelectedImage(editor)); + var size = ImageSize.getImageSize(getSelectedImage(editor)); var flippedSize = size ? { w: size.h, h: size.w } : null; return selectedImageOperation(editor, imageUploadTimerState, function (imageResult) { - return ImageTransformations.rotate(imageResult, angle); + return rotate$1(imageResult, angle); }, flippedSize)(); }; }; var flip$2 = function (editor, imageUploadTimerState, axis) { return function () { return selectedImageOperation(editor, imageUploadTimerState, function (imageResult) { - return ImageTransformations.flip(imageResult, axis); + return flip$1(imageResult, axis); })(); }; }; var editImageDialog = function (editor, imageUploadTimerState) { return function () { - var img = getSelectedImage(editor), originalSize = ImageSize$1.getNaturalImageSize(img); + var img = getSelectedImage(editor), originalSize = ImageSize.getNaturalImageSize(img); var handleDialogBlob = function (blob) { return new global$3(function (resolve) { - BlobConversions.blobToImage(blob).then(function (newImage) { - var newSize = ImageSize$1.getNaturalImageSize(newImage); + blobToImage$1(blob).then(function (newImage) { + var newSize = ImageSize.getNaturalImageSize(newImage); if (originalSize.w !== newSize.w || originalSize.h !== newSize.h) { - if (ImageSize$1.getImageSize(img)) { - ImageSize$1.setImageSize(img, newSize); + if (ImageSize.getImageSize(img)) { + ImageSize.setImageSize(img, newSize); } } - URL$1.revokeObjectURL(newImage.src); + URL.revokeObjectURL(newImage.src); resolve(blob); }); }); }; var openDialog = function (editor, imageResult) { - return Dialog.edit(editor, imageResult).then(handleDialogBlob).then(ResultConversions.blobToImageResult).then(function (imageResult) { + return Dialog.edit(editor, imageResult).then(handleDialogBlob).then(blobToImageResult).then(function (imageResult) { return updateSelectedImage(editor, imageResult, true, imageUploadTimerState); }, function () { }); }; - findSelectedBlob(editor).then(ResultConversions.blobToImageResult).then(curry(openDialog, editor), function (error) { + findSelectedBlob(editor).then(blobToImageResult).then(curry(openDialog, editor), function (error) { displayError(editor, error); }); }; @@ -3649,5 +2998,5 @@ var imagetools = (function () { return Plugin; -}()); +}(window)); })(); diff --git a/plugins/imagetools/plugin.min.js b/plugins/imagetools/plugin.min.js index ecc0aefa..f1b6a111 100644 --- a/plugins/imagetools/plugin.min.js +++ b/plugins/imagetools/plugin.min.js @@ -1 +1 @@ -!function(){"use strict";var r=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return r(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),$=tinymce.util.Tools.resolve("tinymce.util.Tools");function n(t,e){return i(document.createElement("canvas"),t,e)}function o(t){return t.getContext("2d")}function i(t,e,n){return t.width=e,t.height=n,t}var h={create:n,clone:function(t){var e;return o(e=n(t.width,t.height)).drawImage(t,0,0),e},resize:i,get2dContext:o,get3dContext:function(t){var e=null;try{e=t.getContext("webgl")||t.getContext("experimental-webgl")}catch(n){}return e||(e=null),e}},p={getWidth:function(t){return t.naturalWidth||t.width},getHeight:function(t){return t.naturalHeight||t.height}},g=window.Promise?window.Promise:function(){var t=function(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=null,this._value=null,this._deferreds=[],l(t,r(o,this),r(a,this))},e=t.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(t){setTimeout(t,1)};function r(t,e){return function(){t.apply(e,arguments)}}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(r){var o=this;null!==this._state?e(function(){var t=o._state?r.onFulfilled:r.onRejected;if(null!==t){var e;try{e=t(o._value)}catch(n){return void r.reject(n)}r.resolve(e)}else(o._state?r.resolve:r.reject)(o._value)}):this._deferreds.push(r)}function o(t){try{if(t===this)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var e=t.then;if("function"==typeof e)return void l(r(e,t),r(o,this),r(a,this))}this._state=!0,this._value=t,u.call(this)}catch(n){a.call(this,n)}}function a(t){this._state=!1,this._value=t,u.call(this)}function u(){for(var t=0,e=this._deferreds.length;tthis.length())return null;for(var n=this.littleEndian?0:-8*(e-1),r=0,o=0;r=s.length())throw new Error("Invalid Exif data.");"ASCII"!==i?(f=s.asArray(i,c,a),l=1==a?f[0]:f,it.hasOwnProperty(o)&&"object"!=typeof l?d[o]=it[o][l]:d[o]=l):d[o]=s.STRING(c,a).replace(/\0$/,"").trim()}return d},t}(),ut=function(t){var e,n,r=[],o=0;for(e=2;e<=t.length();)if(65488<=(n=t.SHORT(e))&&n<=65495)e+=2;else{if(65498===n||65497===n)break;o=t.SHORT(e+2)+2,65505<=n&&n<=65519&&r.push({hex:n,name:"APP"+(15&n),start:e,length:o,segment:t.SEGMENT(e,o)}),e+=o}return r},ct=function(u){return k.blobToArrayBuffer(u).then(function(t){try{var e=new tt(t);if(65496===e.SHORT(0)){var n=ut(e),r=n.filter(function(t){return"APP1"===t.name}),o={};if(!r.length)return g.reject("Headers did not include required information");var i=new at(r[0].segment);return(o={tiff:i.TIFF(),exif:i.EXIF(),gps:i.GPS(),thumb:i.thumb()}).rawHeaders=n,o}return g.reject("Image was not a jpeg")}catch(a){return g.reject("Unsupported format or not an image: "+u.type+" (Exception: "+a.message+")")}})},lt=function(t,e){return Q.rotate(t,e)},st={invert:function(t){return K.invert(t)},sharpen:function(t){return K.sharpen(t)},emboss:function(t){return K.emboss(t)},brightness:function(t,e){return K.brightness(t,e)},hue:function(t,e){return K.hue(t,e)},saturate:function(t,e){return K.saturate(t,e)},contrast:function(t,e){return K.contrast(t,e)},grayscale:function(t,e){return K.grayscale(t,e)},sepia:function(t,e){return K.sepia(t,e)},colorize:function(t,e,n,r){return K.colorize(t,e,n,r)},gamma:function(t,e){return K.gamma(t,e)},exposure:function(t,e){return K.exposure(t,e)},flip:function(t,e){return Q.flip(t,e)},crop:function(t,e,n,r,o){return Q.crop(t,e,n,r,o)},resize:function(t,e,n){return Q.resize(t,e,n)},rotate:lt,exifRotate:function(e){return e.toBlob().then(ct).then(function(t){switch(t.tiff.Orientation){case 6:return lt(e,90);case 3:return lt(e,180);case 8:return lt(e,270);default:return e}},function(){return e})}},ft=function(t){return t.toBlob()},dt={blobToImageResult:function(t){return M.fromBlob(t)},fromBlobAndUrlSync:function(t,e){return M.fromBlobAndUrlSync(t,e)},imageToImageResult:function(t){return M.fromImage(t)},imageResultToBlob:function(t,e,n){return e===undefined&&n===undefined?ft(t):t.toAdjustedBlob(e,n)},imageResultToOriginalBlob:ft,imageResultToDataURL:function(t){return t.toDataURL()}},ht=function(){return S.getOrDie("URL")},pt={createObjectURL:function(t){return ht().createObjectURL(t)},revokeObjectURL:function(t){ht().revokeObjectURL(t)}},gt=tinymce.util.Tools.resolve("tinymce.util.Delay"),mt=tinymce.util.Tools.resolve("tinymce.util.Promise"),yt=tinymce.util.Tools.resolve("tinymce.util.URI"),vt=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),bt=tinymce.util.Tools.resolve("tinymce.ui.Factory"),wt=tinymce.util.Tools.resolve("tinymce.geom.Rect"),xt=function(n){return new mt(function(t){var e=function(){n.removeEventListener("load",e),t(n)};n.complete?t(n):n.addEventListener("load",e)})},It=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),Tt=tinymce.util.Tools.resolve("tinymce.util.Observable"),Rt=tinymce.util.Tools.resolve("tinymce.util.VK"),St=0,Ot={create:function(t){return new(bt.get("Control").extend({Defaults:{classes:"imagepanel"},selection:function(t){return arguments.length?(this.state.set("rect",t),this):this.state.get("rect")},imageSize:function(){var t=this.state.get("viewRect");return{w:t.w,h:t.h}},toggleCropRect:function(t){this.state.set("cropEnabled",t)},imageSrc:function(t){var o=this,i=new Image;i.src=t,xt(i).then(function(){var t,e,n=o.state.get("viewRect");if((e=o.$el.find("img"))[0])e.replaceWith(i);else{var r=document.createElement("div");r.className="mce-imagepanel-bg",o.getEl().appendChild(r),o.getEl().appendChild(i)}t={x:0,y:0,w:i.naturalWidth,h:i.naturalHeight},o.state.set("viewRect",t),o.state.set("rect",wt.inflate(t,-20,-20)),n&&n.w===t.w&&n.h===t.h||o.zoomFit(),o.repaintImage(),o.fire("load")})},zoom:function(t){return arguments.length?(this.state.set("zoom",t),this):this.state.get("zoom")},postRender:function(){return this.imageSrc(this.settings.imageSrc),this._super()},zoomFit:function(){var t,e,n,r,o,i;t=this.$el.find("img"),e=this.getEl().clientWidth,n=this.getEl().clientHeight,r=t[0].naturalWidth,o=t[0].naturalHeight,1<=(i=Math.min((e-10)/r,(n-10)/o))&&(i=1),this.zoom(i)},repaintImage:function(){var t,e,n,r,o,i,a,u,c,l,s;s=this.getEl(),c=this.zoom(),l=this.state.get("rect"),a=this.$el.find("img"),u=this.$el.find(".mce-imagepanel-bg"),o=s.offsetWidth,i=s.offsetHeight,n=a[0].naturalWidth*c,r=a[0].naturalHeight*c,t=Math.max(0,o/2-n/2),e=Math.max(0,i/2-r/2),a.css({left:t,top:e,width:n,height:r}),u.css({left:t,top:e,width:n,height:r}),this.cropRect&&(this.cropRect.setRect({x:l.x*c+t,y:l.y*c+e,w:l.w*c,h:l.h*c}),this.cropRect.setClampRect({x:t,y:e,w:n,h:r}),this.cropRect.setViewPortRect({x:0,y:0,w:o,h:i}))},bindStates:function(){var r=this;function n(t){r.cropRect=function(l,n,s,r,o){var f,a,t,i,e="mce-",u=e+"crid-"+St++;function d(t,e){return{x:e.x-t.x,y:e.y-t.y,w:e.w,h:e.h}}function c(t,e,n,r){var o,i,a,u,c;o=e.x,i=e.y,a=e.w,u=e.h,o+=n*t.deltaX,i+=r*t.deltaY,(a+=n*t.deltaW)<20&&(a=20),(u+=r*t.deltaH)<20&&(u=20),c=l=wt.clamp({x:o,y:i,w:a,h:u},s,"move"===t.name),c=d(s,c),f.fire("updateRect",{rect:c}),g(c)}function h(e){function t(t,e){e.h<0&&(e.h=0),e.w<0&&(e.w=0),It("#"+u+"-"+t,r).css({left:e.x,top:e.y,width:e.w,height:e.h})}$.each(a,function(t){It("#"+u+"-"+t.name,r).css({left:e.w*t.xMul+e.x,top:e.h*t.yMul+e.y})}),t("top",{x:n.x,y:n.y,w:n.w,h:e.y-n.y}),t("right",{x:e.x+e.w,y:e.y,w:n.w-e.x-e.w+n.x,h:e.h}),t("bottom",{x:n.x,y:e.y+e.h,w:n.w,h:n.h-e.y-e.h+n.y}),t("left",{x:n.x,y:e.y,w:e.x-n.x,h:e.h}),t("move",e)}function p(t){h(l=t)}function g(t){var e,n;p((e=s,{x:(n=t).x+e.x,y:n.y+e.y,w:n.w,h:n.h}))}return a=[{name:"move",xMul:0,yMul:0,deltaX:1,deltaY:1,deltaW:0,deltaH:0,label:"Crop Mask"},{name:"nw",xMul:0,yMul:0,deltaX:1,deltaY:1,deltaW:-1,deltaH:-1,label:"Top Left Crop Handle"},{name:"ne",xMul:1,yMul:0,deltaX:0,deltaY:1,deltaW:1,deltaH:-1,label:"Top Right Crop Handle"},{name:"sw",xMul:0,yMul:1,deltaX:1,deltaY:0,deltaW:-1,deltaH:1,label:"Bottom Left Crop Handle"},{name:"se",xMul:1,yMul:1,deltaX:0,deltaY:0,deltaW:1,deltaH:1,label:"Bottom Right Crop Handle"}],i=["top","right","bottom","left"],It('
').appendTo(r),$.each(i,function(t){It("#"+u,r).append('