Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: tinymce @ 4.8.5 .. 4.9.4

changelog.txt

@@ -1,3 +1,39 @@
+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_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
+ Fixed a bug where only a few function key names could be used when creating keyboard shortcuts. #TINY-3146
+ Fixed a bug where it wasn't possible to enter spaces into an editor after pressing shift+enter. #TINY-3099
+ Fixed a bug where no caret would be rendered after backspacing to a contenteditable false element. #TINY-2998
+ Fixed a bug where deletion to/from indented lists would leave list fragments in the editor. #TINY-2981
+Version 4.9.2 (2018-12-17)
+ Fixed a bug with pressing the space key on IE 11 would result in nbsp characters being inserted between words at the end of a block. #TINY-2996
+ Fixed a bug where character composition using quote and space on US International keyboards would produce a space instead of a quote. #TINY-2999
+ Fixed a bug where remove format wouldn't remove the inner most inline element in some situations. #TINY-2982
+ Fixed a bug where outdenting an list item would affect attributes on other list items within the same list. #TINY-2971
+ Fixed a bug where the DomParser filters wouldn't be applied for elements created when parsing invalid html. #TINY-2978
+ Fixed a bug where setProgressState wouldn't automatically close floating ui elements like menus. #TINY-2896
+ Fixed a bug where it wasn't possible to navigate out of a figcaption element using the arrow keys. #TINY-2894
+ Fixed a bug where enter key before an image inside a link would remove the image. #TINY-2780
+Version 4.9.1 (2018-12-04)
+ Added functionality to insert html to the replacement feature of the Textpattern Plugin. #TINY-2839
+ Fixed a bug where `editor.selection.getContent({format: 'text'})` didn't work as expected in IE11 on an unfocused editor. #TINY-2862
+ Fixed a bug in the Textpattern Plugin where the editor would get an incorrect selection after inserting a text pattern on Safari. #TINY-2838
+ Fixed a bug where the space bar didn't work correctly in editors with the forced_root_block setting set to false. #TINY-2816
+Version 4.9.0 (2018-11-27)
+ Added a replace feature to the Textpattern Plugin. #TINY-1908
+ Added functionality to the Lists Plugin that improves the indentation logic. #TINY-1790
+ Fixed a bug where it wasn't possible to delete/backspace when the caret was between a contentEditable=false element and a BR. #TINY-2372
+ Fixed a bug where copying table cells without a text selection would fail to copy anything. #TINY-1789
+ Implemented missing `autosave_restore_when_empty` functionality in the Autosave Plugin. Patch contributed by gzzo. #GH-4447
+ Reduced insertion of unnecessary nonbreaking spaces in the editor. #TINY-1879
Version 4.8.5 (2018-10-30)
Added a content_css_cors setting to the editor that adds the crossorigin="anonymous" attribute to link tags added by the StyleSheetLoader. #TINY-1909
Fixed a bug where trying to remove formatting with a collapsed selection range would throw an exception. #GH-4636

composer.json

@@ -1,6 +1,6 @@
{
"name": "tinymce/tinymce",
- "version": "4.8.5",
+ "version": "4.9.4",
"description": "Web based JavaScript HTML WYSIWYG editor control.",
"license": [
"LGPL-2.1-only"

package.json

@@ -1,6 +1,6 @@
{
"name": "tinymce",
- "version": "4.8.5",
+ "version": "4.9.4",
"repository": {
"type": "git",
"url": "https://github.com/tinymce/tinymce-dist.git"

plugins/autosave/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var autosave = (function () {
+var autosave = (function (domGlobals) {
'use strict';
var Cell = function (initial) {
@@ -35,30 +35,25 @@
var fireRemoveDraft = function (editor) {
return editor.fire('RemoveDraft');
};
- var Events = {
- fireRestoreDraft: fireRestoreDraft,
- fireStoreDraft: fireStoreDraft,
- fireRemoveDraft: fireRemoveDraft
- };
- var parse = function (time, defaultTime) {
+ var parse = function (timeString, defaultTime) {
var multiples = {
s: 1000,
m: 60000
};
- time = /^(\d+)([ms]?)$/.exec('' + (time || defaultTime));
- return (time[2] ? multiples[time[2]] : 1) * parseInt(time, 10);
+ var toParse = timeString || defaultTime;
+ var parsedTime = /^(\d+)([ms]?)$/.exec('' + toParse);
+ return (parsedTime[2] ? multiples[parsedTime[2]] : 1) * parseInt(toParse, 10);
};
- var Time = { parse: parse };
var shouldAskBeforeUnload = function (editor) {
return editor.getParam('autosave_ask_before_unload', true);
};
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;
};
@@ -66,17 +61,10 @@
return editor.getParam('autosave_restore_when_empty', false);
};
var getAutoSaveInterval = function (editor) {
- return Time.parse(editor.settings.autosave_interval, '30s');
+ return parse(editor.settings.autosave_interval, '30s');
};
var getAutoSaveRetention = function (editor) {
- return Time.parse(editor.settings.autosave_retention, '20m');
- };
- var Settings = {
- shouldAskBeforeUnload: shouldAskBeforeUnload,
- getAutoSavePrefix: getAutoSavePrefix,
- shouldRestoreWhenEmpty: shouldRestoreWhenEmpty,
- getAutoSaveInterval: getAutoSaveInterval,
- getAutoSaveRetention: getAutoSaveRetention
+ return parse(editor.settings.autosave_retention, '20m');
};
var isEmpty = function (editor, html) {
@@ -85,41 +73,41 @@
return html === '' || new RegExp('^<' + forcedRootBlockName + '[^>]*>((\xA0|&nbsp;|[ \t]|<br[^>]*>)+?|)</' + forcedRootBlockName + '>|<br>$', 'i').test(html);
};
var hasDraft = function (editor) {
- var time = parseInt(global$1.getItem(Settings.getAutoSavePrefix(editor) + 'time'), 10) || 0;
- if (new Date().getTime() - time > Settings.getAutoSaveRetention(editor)) {
+ var time = parseInt(global$1.getItem(getAutoSavePrefix(editor) + 'time'), 10) || 0;
+ if (new Date().getTime() - time > getAutoSaveRetention(editor)) {
removeDraft(editor, false);
return false;
}
return true;
};
var removeDraft = function (editor, fire) {
- var prefix = Settings.getAutoSavePrefix(editor);
+ var prefix = getAutoSavePrefix(editor);
global$1.removeItem(prefix + 'draft');
global$1.removeItem(prefix + 'time');
if (fire !== false) {
- Events.fireRemoveDraft(editor);
+ fireRemoveDraft(editor);
}
};
var storeDraft = function (editor) {
- var prefix = Settings.getAutoSavePrefix(editor);
+ var prefix = getAutoSavePrefix(editor);
if (!isEmpty(editor) && editor.isDirty()) {
global$1.setItem(prefix + 'draft', editor.getContent({
format: 'raw',
no_events: true
}));
global$1.setItem(prefix + 'time', new Date().getTime().toString());
- Events.fireStoreDraft(editor);
+ fireStoreDraft(editor);
}
};
var restoreDraft = function (editor) {
- var prefix = Settings.getAutoSavePrefix(editor);
+ var prefix = getAutoSavePrefix(editor);
if (hasDraft(editor)) {
editor.setContent(global$1.getItem(prefix + 'draft'), { format: 'raw' });
- Events.fireRestoreDraft(editor);
+ fireRestoreDraft(editor);
}
};
var startStoreDraft = function (editor, started) {
- var interval = Settings.getAutoSaveInterval(editor);
+ var interval = getAutoSaveInterval(editor);
if (!started.get()) {
setInterval(function () {
if (!editor.removed) {
@@ -136,32 +124,31 @@
});
editor.focus();
};
- var Storage = {
- isEmpty: isEmpty,
- hasDraft: hasDraft,
- removeDraft: removeDraft,
- storeDraft: storeDraft,
- restoreDraft: restoreDraft,
- startStoreDraft: startStoreDraft,
- restoreLastDraft: restoreLastDraft
- };
- var curry = function (f, editor) {
+ function curry(fn) {
+ var initialArgs = [];
+ for (var _i = 1; _i < arguments.length; _i++) {
+ initialArgs[_i - 1] = arguments[_i];
+ }
return function () {
- var args = Array.prototype.slice.call(arguments);
- return f.apply(null, [editor].concat(args));
- };
+ var restArgs = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ restArgs[_i] = arguments[_i];
+ }
+ var all = initialArgs.concat(restArgs);
+ return fn.apply(null, all);
};
+ }
+
var get = function (editor) {
return {
- hasDraft: curry(Storage.hasDraft, editor),
- storeDraft: curry(Storage.storeDraft, editor),
- restoreDraft: curry(Storage.restoreDraft, editor),
- removeDraft: curry(Storage.removeDraft, editor),
- isEmpty: curry(Storage.isEmpty, editor)
+ hasDraft: curry(hasDraft, editor),
+ storeDraft: curry(storeDraft, editor),
+ restoreDraft: curry(restoreDraft, editor),
+ removeDraft: curry(removeDraft, editor),
+ isEmpty: curry(isEmpty, editor)
};
};
- var Api = { get: get };
var global$3 = tinymce.util.Tools.resolve('tinymce.EditorManager');
@@ -171,56 +158,59 @@
if (editor.plugins.autosave) {
editor.plugins.autosave.storeDraft();
}
- if (!msg && editor.isDirty() && Settings.shouldAskBeforeUnload(editor)) {
+ if (!msg && editor.isDirty() && shouldAskBeforeUnload(editor)) {
msg = editor.translate('You have unsaved changes are you sure you want to navigate away?');
}
});
return msg;
};
var setup = function (editor) {
- window.onbeforeunload = global$3._beforeUnloadHandler;
+ domGlobals.window.onbeforeunload = global$3._beforeUnloadHandler;
};
- var BeforeUnload = { setup: setup };
var postRender = function (editor, started) {
return function (e) {
var ctrl = e.control;
- ctrl.disabled(!Storage.hasDraft(editor));
+ ctrl.disabled(!hasDraft(editor));
editor.on('StoreDraft RestoreDraft RemoveDraft', function () {
- ctrl.disabled(!Storage.hasDraft(editor));
+ ctrl.disabled(!hasDraft(editor));
});
- Storage.startStoreDraft(editor, started);
+ startStoreDraft(editor, started);
};
};
var register = function (editor, started) {
editor.addButton('restoredraft', {
title: 'Restore last draft',
onclick: function () {
- Storage.restoreLastDraft(editor);
+ restoreLastDraft(editor);
},
onPostRender: postRender(editor, started)
});
editor.addMenuItem('restoredraft', {
text: 'Restore last draft',
onclick: function () {
- Storage.restoreLastDraft(editor);
+ restoreLastDraft(editor);
},
onPostRender: postRender(editor, started),
context: 'file'
});
};
- var Buttons = { register: register };
global.add('autosave', function (editor) {
var started = Cell(false);
- BeforeUnload.setup(editor);
- Buttons.register(editor, started);
- return Api.get(editor);
+ setup(editor);
+ register(editor, started);
+ editor.on('init', function () {
+ if (shouldRestoreWhenEmpty(editor) && editor.dom.isEmpty(editor.getBody())) {
+ restoreDraft(editor);
+ }
+ });
+ return get(editor);
});
function Plugin () {
}
return Plugin;
-}());
+}(window));
})();

plugins/autosave/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var n=function(t){var e=t,r=function(){return e};return{get:r,set:function(t){e=t},clone:function(){return n(r())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),r=function(t){return t.fire("RestoreDraft")},i=function(t){return t.fire("StoreDraft")},s=function(t){return t.fire("RemoveDraft")},e=function(t,e){return((t=/^(\d+)([ms]?)$/.exec(""+(t||e)))[2]?{s:1e3,m:6e4}[t[2]]:1)*parseInt(t,10)},u=function(t){return t.getParam("autosave_ask_before_unload",!0)},f=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)},c=function(t){return e(t.settings.autosave_interval,"30s")},l=function(t){return e(t.settings.autosave_retention,"20m")},m=function(t,e){var r=t.settings.forced_root_block;return""===(e=o.trim(void 0===e?t.getBody().innerHTML:e))||new RegExp("^<"+r+"[^>]*>((\xa0|&nbsp;|[ \t]|<br[^>]*>)+?|)</"+r+">|<br>$","i").test(e)},v=function(t){var e=parseInt(a.getItem(f(t)+"time"),10)||0;return!((new Date).getTime()-e>l(t)&&(d(t,!1),1))},d=function(t,e){var r=f(t);a.removeItem(r+"draft"),a.removeItem(r+"time"),!1!==e&&s(t)},D=function(t){var e=f(t);!m(t)&&t.isDirty()&&(a.setItem(e+"draft",t.getContent({format:"raw",no_events:!0})),a.setItem(e+"time",(new Date).getTime().toString()),i(t))},g=function(t){var e=f(t);v(t)&&(t.setContent(a.getItem(e+"draft"),{format:"raw"}),r(t))},y={isEmpty:m,hasDraft:v,removeDraft:d,storeDraft:D,restoreDraft:g,startStoreDraft:function(t,e){var r=c(t);e.get()||(setInterval(function(){t.removed||D(t)},r),e.set(!0))},restoreLastDraft:function(t){t.undoManager.transact(function(){g(t),d(t)}),t.focus()}},p=function(e,r){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[r].concat(t))}},h=function(t){return{hasDraft:p(y.hasDraft,t),storeDraft:p(y.storeDraft,t),restoreDraft:p(y.restoreDraft,t),removeDraft:p(y.removeDraft,t),isEmpty:p(y.isEmpty,t)}},_=tinymce.util.Tools.resolve("tinymce.EditorManager");_._beforeUnloadHandler=function(){var e;return o.each(_.get(),function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&u(t)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e};var b=function(t){window.onbeforeunload=_._beforeUnloadHandler},I=function(r,n){return function(t){var e=t.control;e.disabled(!y.hasDraft(r)),r.on("StoreDraft RestoreDraft RemoveDraft",function(){e.disabled(!y.hasDraft(r))}),y.startStoreDraft(r,n)}},w=function(t,e){t.addButton("restoredraft",{title:"Restore last draft",onclick:function(){y.restoreLastDraft(t)},onPostRender:I(t,e)}),t.addMenuItem("restoredraft",{text:"Restore last draft",onclick:function(){y.restoreLastDraft(t)},onPostRender:I(t,e),context:"file"})};t.add("autosave",function(t){var e=n(!1);return b(t),w(t,e),h(t)})}();
\ No newline at end of file
+!function(a){"use strict";var i=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return i(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=tinymce.util.Tools.resolve("tinymce.util.LocalStorage"),o=tinymce.util.Tools.resolve("tinymce.util.Tools"),u=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)},s=function(t){var e=t.getParam("autosave_prefix","tinymce-autosave-{path}{query}{hash}-{id}-");return e=(e=(e=(e=e.replace(/\{path\}/g,a.document.location.pathname)).replace(/\{query\}/g,a.document.location.search)).replace(/\{hash\}/g,a.document.location.hash)).replace(/\{id\}/g,t.id)},c=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|&nbsp;|[ \t]|<br[^>]*>)+?|)</"+n+">|<br>$","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<arguments.length;t++)o[t-1]=arguments[t];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o.concat(t);return r.apply(null,n)}}var p=tinymce.util.Tools.resolve("tinymce.EditorManager");p._beforeUnloadHandler=function(){var e;return o.each(p.get(),function(t){t.plugins.autosave&&t.plugins.autosave.storeDraft(),!e&&t.isDirty()&&t.getParam("autosave_ask_before_unload",!0)&&(e=t.translate("You have unsaved changes are you sure you want to navigate away?"))}),e};var h=function(n,r){return function(t){var e=t.control;e.disabled(!f(n)),n.on("StoreDraft RestoreDraft RemoveDraft",function(){e.disabled(!f(n))}),d(n,r)}};t.add("autosave",function(t){var e,n,r,o=i(!1);return a.window.onbeforeunload=p._beforeUnloadHandler,n=o,(e=t).addButton("restoredraft",{title:"Restore last draft",onclick:function(){g(e)},onPostRender:h(e,n)}),e.addMenuItem("restoredraft",{text:"Restore last draft",onclick:function(){g(e)},onPostRender:h(e,n),context:"file"}),t.on("init",function(){t.getParam("autosave_restore_when_empty",!1)&&t.dom.isEmpty(t.getBody())&&v(t)}),{hasDraft:y(f,r=t),storeDraft:y(m,r),restoreDraft:y(v,r),removeDraft:y(l,r),isEmpty:y(c,r)}})}(window);
\ No newline at end of file

plugins/codesample/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var codesample = (function () {
+var codesample = (function (domGlobals) {
'use strict';
var Cell = function (initial) {
@@ -43,9 +43,9 @@
getDialogMinHeight: getDialogMinHeight
};
- var window$$1 = {};
- var global$2 = window$$1;
- var _self = typeof window$$1 !== 'undefined' ? window$$1 : typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : {};
+ var window = {};
+ var global$2 = window;
+ var _self = typeof window !== 'undefined' ? window : typeof WorkerGlobalScope !== 'undefined' && domGlobals.self instanceof WorkerGlobalScope ? domGlobals.self : {};
var Prism = function () {
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
var _ = _self.Prism = {
@@ -136,27 +136,27 @@
},
plugins: {},
highlightAll: function (async, callback) {
- var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
+ var elements = domGlobals.document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
for (var i = 0, element = void 0; element = elements[i++];) {
_.highlightElement(element, async === true, callback);
}
},
highlightElement: function (element, async, callback) {
- var language, grammar, parent$$1 = element;
- while (parent$$1 && !lang.test(parent$$1.className)) {
- parent$$1 = parent$$1.parentNode;
+ var language, grammar, parent = element;
+ while (parent && !lang.test(parent.className)) {
+ parent = parent.parentNode;
}
- if (parent$$1) {
- language = (parent$$1.className.match(lang) || [
+ if (parent) {
+ language = (parent.className.match(lang) || [
,
''
])[1];
grammar = _.languages[language];
}
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
- parent$$1 = element.parentNode;
- if (/pre/i.test(parent$$1.nodeName)) {
- parent$$1.className = parent$$1.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
+ parent = element.parentNode;
+ if (/pre/i.test(parent.nodeName)) {
+ parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
}
var code = element.textContent;
var env = {
@@ -171,7 +171,7 @@
}
_.hooks.run('before-highlight', env);
if (async && _self.Worker) {
- var worker = new Worker(_.filename);
+ var worker = new domGlobals.Worker(_.filename);
worker.onmessage = function (evt) {
env.highlightedCode = evt.data;
_.hooks.run('before-insert', env);
@@ -264,13 +264,13 @@
},
hooks: {
all: {},
- add: function (name$$1, callback) {
+ add: function (name, callback) {
var hooks = _.hooks.all;
- hooks[name$$1] = hooks[name$$1] || [];
- hooks[name$$1].push(callback);
+ hooks[name] = hooks[name] || [];
+ hooks[name].push(callback);
},
- run: function (name$$1, env) {
- var callbacks = _.hooks.all[name$$1];
+ run: function (name, env) {
+ var callbacks = _.hooks.all[name];
if (!callbacks || !callbacks.length) {
return;
}
@@ -285,7 +285,7 @@
this.content = content;
this.alias = alias;
};
- Token.stringify = function (o, language, parent$$1) {
+ Token.stringify = function (o, language, parent) {
if (typeof o === 'string') {
return o;
}
@@ -296,7 +296,7 @@
}
var env = {
type: o.type,
- content: Token.stringify(o.content, language, parent$$1),
+ content: Token.stringify(o.content, language, parent),
tag: 'span',
classes: [
'token',
@@ -304,7 +304,7 @@
],
attributes: {},
language: language,
- parent: parent$$1
+ parent: parent
};
if (env.type === 'comment') {
env.attributes.spellcheck = 'true';
@@ -315,8 +315,8 @@
}
_.hooks.run('wrap', env);
var attributes = '';
- for (var name$$1 in env.attributes) {
- attributes += (attributes ? ' ' : '') + name$$1 + '="' + (env.attributes[name$$1] || '') + '"';
+ for (var name in env.attributes) {
+ attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
}
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
};
@@ -963,5 +963,5 @@
return Plugin;
-}());
+}(window));
})();

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,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){switch(S.util.type(e)){case"Object":var t={};for(var a in e)e.hasOwnProperty(a)&&(t[a]=S.util.clone(e[a]));return t;case"Array":return e.map&&e.map(function(e){return S.util.clone(e)})}return e}},languages:{extend:function(e,t){var a=S.util.clone(S.languages[e]);for(var n in t)a[n]=t[n];return a},insertBefore:function(a,e,t,n){var i=(n=n||S.languages)[a];if(2===arguments.length){for(var r in t=e)t.hasOwnProperty(r)&&(i[r]=t[r]);return i}var s={};for(var o in i)if(i.hasOwnProperty(o)){if(o===e)for(var r in t)t.hasOwnProperty(r)&&(s[r]=t[r]);s[o]=i[o]}return S.languages.DFS(S.languages,function(e,t){t===n[a]&&e!==a&&(this[e]=s)}),n[a]=s},DFS:function(e,t,a){for(var n in e)e.hasOwnProperty(n)&&(t.call(e,n,e[n],a||n),"Object"===S.util.type(e[n])?S.languages.DFS(e[n],t):"Array"===S.util.type(e[n])&&S.languages.DFS(e[n],t,n))}},plugins:{},highlightAll:function(e,t){for(var a=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),n=0,i=void 0;i=a[n++];)S.highlightElement(i,!0===e,t)},highlightElement:function(e,t,a){for(var n,i,r=e;r&&!c.test(r.className);)r=r.parentNode;r&&(n=(r.className.match(c)||[,""])[1],i=S.languages[n]),e.className=e.className.replace(c,"").replace(/\s+/g," ")+" language-"+n,r=e.parentNode,/pre/i.test(r.nodeName)&&(r.className=r.className.replace(c,"").replace(/\s+/g," ")+" language-"+n);var s=e.textContent,o={element:e,language:n,grammar:i,code:s};if(s&&i)if(S.hooks.run("before-highlight",o),t&&u.Worker){var l=new Worker(S.filename);l.onmessage=function(e){o.highlightedCode=e.data,S.hooks.run("before-insert",o),o.element.innerHTML=o.highlightedCode,a&&a.call(o.element),S.hooks.run("after-highlight",o),S.hooks.run("complete",o)},l.postMessage(JSON.stringify({language:o.language,code:o.code,immediateClose:!0}))}else o.highlightedCode=S.highlight(o.code,o.grammar,o.language),S.hooks.run("before-insert",o),o.element.innerHTML=o.highlightedCode,a&&a.call(e),S.hooks.run("after-highlight",o),S.hooks.run("complete",o);else S.hooks.run("complete",o)},highlight:function(e,t,a){var n=S.tokenize(e,t);return o.stringify(S.util.encode(n),a)},tokenize:function(e,t,a){var n=S.Token,i=[e],r=t.rest;if(r){for(var s in r)t[s]=r[s];delete t.rest}e:for(var s in t)if(t.hasOwnProperty(s)&&t[s]){var o=t[s];o="Array"===S.util.type(o)?o:[o];for(var l=0;l<o.length;++l){var c=o[l],u=c.inside,g=!!c.lookbehind,d=0,p=c.alias;c=c.pattern||c;for(var f=0;f<i.length;f++){var h=i[f];if(i.length>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+"</"+n.tag+">"},!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:/<!--[\w\W]*?-->/,prolog:/<\?[\w\W]+?\?>/,doctype:/<!DOCTYPE[\w\W]+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/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(/&amp;/,"&"))}),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:/<style[\w\W]*?>[\w\W]*?<\/style>/i,inside:{tag:{pattern:/<style[\w\W]*?>|<\/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:/<script[\w\W]*?>[\w\W]*?<\/script>/i,inside:{tag:{pattern:/<script[\w\W]*?>|<\/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,'<span class="token php">$1</span>'))}),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('<pre id="__new" class="language-'+a+'">'+n+"</pre>"),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("<code></code>").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,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){switch(S.util.type(e)){case"Object":var t={};for(var a in e)e.hasOwnProperty(a)&&(t[a]=S.util.clone(e[a]));return t;case"Array":return e.map&&e.map(function(e){return S.util.clone(e)})}return e}},languages:{extend:function(e,t){var a=S.util.clone(S.languages[e]);for(var n in t)a[n]=t[n];return a},insertBefore:function(a,e,t,n){var i=(n=n||S.languages)[a];if(2===arguments.length){for(var r in t=e)t.hasOwnProperty(r)&&(i[r]=t[r]);return i}var s={};for(var o in i)if(i.hasOwnProperty(o)){if(o===e)for(var r in t)t.hasOwnProperty(r)&&(s[r]=t[r]);s[o]=i[o]}return S.languages.DFS(S.languages,function(e,t){t===n[a]&&e!==a&&(this[e]=s)}),n[a]=s},DFS:function(e,t,a){for(var n in e)e.hasOwnProperty(n)&&(t.call(e,n,e[n],a||n),"Object"===S.util.type(e[n])?S.languages.DFS(e[n],t):"Array"===S.util.type(e[n])&&S.languages.DFS(e[n],t,n))}},plugins:{},highlightAll:function(e,t){for(var a=u.document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),n=0,i=void 0;i=a[n++];)S.highlightElement(i,!0===e,t)},highlightElement:function(e,t,a){for(var n,i,r=e;r&&!c.test(r.className);)r=r.parentNode;r&&(n=(r.className.match(c)||[,""])[1],i=S.languages[n]),e.className=e.className.replace(c,"").replace(/\s+/g," ")+" language-"+n,r=e.parentNode,/pre/i.test(r.nodeName)&&(r.className=r.className.replace(c,"").replace(/\s+/g," ")+" language-"+n);var s=e.textContent,o={element:e,language:n,grammar:i,code:s};if(s&&i)if(S.hooks.run("before-highlight",o),t&&g.Worker){var l=new u.Worker(S.filename);l.onmessage=function(e){o.highlightedCode=e.data,S.hooks.run("before-insert",o),o.element.innerHTML=o.highlightedCode,a&&a.call(o.element),S.hooks.run("after-highlight",o),S.hooks.run("complete",o)},l.postMessage(JSON.stringify({language:o.language,code:o.code,immediateClose:!0}))}else o.highlightedCode=S.highlight(o.code,o.grammar,o.language),S.hooks.run("before-insert",o),o.element.innerHTML=o.highlightedCode,a&&a.call(e),S.hooks.run("after-highlight",o),S.hooks.run("complete",o);else S.hooks.run("complete",o)},highlight:function(e,t,a){var n=S.tokenize(e,t);return o.stringify(S.util.encode(n),a)},tokenize:function(e,t,a){var n=S.Token,i=[e],r=t.rest;if(r){for(var s in r)t[s]=r[s];delete t.rest}e:for(var s in t)if(t.hasOwnProperty(s)&&t[s]){var o=t[s];o="Array"===S.util.type(o)?o:[o];for(var l=0;l<o.length;++l){var c=o[l],u=c.inside,g=!!c.lookbehind,d=0,p=c.alias;c=c.pattern||c;for(var f=0;f<i.length;f++){var h=i[f];if(i.length>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+"</"+n.tag+">"},!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:/<!--[\w\W]*?-->/,prolog:/<\?[\w\W]+?\?>/,doctype:/<!DOCTYPE[\w\W]+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/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(/&amp;/,"&"))}),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:/<style[\w\W]*?>[\w\W]*?<\/style>/i,inside:{tag:{pattern:/<style[\w\W]*?>|<\/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:/<script[\w\W]*?>[\w\W]*?<\/script>/i,inside:{tag:{pattern:/<script[\w\W]*?>|<\/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,'<span class="token php">$1</span>'))}),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('<pre id="__new" class="language-'+a+'">'+n+"</pre>"),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("<code></code>").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

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 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 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 @@
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 @@
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 @@
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 @@
return Plugin;
-}());
+}(window));
})();

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

plugins/help/plugin.js

@@ -9,33 +9,27 @@
return value;
};
};
- var curry = function (f) {
- var x = [];
+ function curry(fn) {
+ var initialArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
- x[_i - 1] = arguments[_i];
+ initialArgs[_i - 1] = arguments[_i];
}
- var args = new Array(arguments.length - 1);
- for (var i = 1; i < arguments.length; i++)
- args[i - 1] = arguments[i];
return function () {
- var x = [];
+ var restArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ restArgs[_i] = arguments[_i];
}
- var newArgs = new Array(arguments.length);
- for (var j = 0; j < newArgs.length; j++)
- newArgs[j] = arguments[j];
- var all = args.concat(newArgs);
- return f.apply(null, all);
- };
+ var all = initialArgs.concat(restArgs);
+ return fn.apply(null, all);
};
+ }
var not = function (f) {
return function () {
- var x = [];
+ var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ args[_i] = arguments[_i];
}
- return !f.apply(null, arguments);
+ return !f.apply(null, args);
};
};
var never = constant(false);
@@ -50,13 +44,13 @@
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 noop = function () {
};
var nul = function () {
return null;
@@ -72,17 +66,17 @@
isSome: never$1,
isNone: always$1,
getOr: id,
- getOrThunk: call$$1,
+ getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: nul,
getOrUndefined: undef,
or: id,
- orThunk: call$$1,
+ orThunk: call,
map: none,
ap: none,
- each: noop$$1,
+ each: noop,
bind: none,
flatten: none,
exists: never$1,
@@ -566,8 +560,8 @@
});
};
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);

plugins/help/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var e,t,n,r,o,a,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),l=function(e){return function(){return e}},c=function(a){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var i=new Array(arguments.length-1),n=1;n<arguments.length;n++)i[n-1]=arguments[n];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var o=i.concat(n);return a.apply(null,o)}},u=l(!1),s=l(!0),m=u,f=s,d=function(){return p},p=(r={fold:function(e,t){return e()},is:m,isSome:m,isNone:f,getOr:n=function(e){return e},getOrThunk:t=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:n,orThunk:t,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:m,forall:f,filter:d,equals:e=function(e){return e.isNone()},equals_:e,toArray:function(){return[]},toString:l("none()")},Object.freeze&&Object.freeze(r),r),h=function(n){var e=function(){return n},t=function(){return o},r=function(e){return e(n)},o={fold:function(e,t){return t(n)},is:function(e){return n===e},isSome:f,isNone:m,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return h(e(n))},ap:function(e){return e.fold(d,function(e){return h(e(n))})},each:function(e){e(n)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(n)?o:p},equals:function(e){return e.is(n)},equals_:function(e,t){return e.fold(m,function(e){return t(n,e)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},y={some:h,none:d,from:function(e){return null===e||e===undefined?p:h(e)}},g=(o="function",function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&Array.prototype.isPrototypeOf(e)?"array":"object"===t&&String.prototype.isPrototypeOf(e)?"string":t}(e)===o}),k=(a=Array.prototype.indexOf)===undefined?function(e,t){return x(e,t)}:function(e,t){return a.call(e,t)},v=function(e,t){return-1<k(e,t)},b=function(e,t){for(var n=e.length,r=new Array(n),o=0;o<n;o++){var a=e[o];r[o]=t(a,o,e)}return r},x=function(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return n;return-1},w=(Array.prototype.slice,g(Array.from)&&Array.from,tinymce.util.Tools.resolve("tinymce.util.I18n")),A=tinymce.util.Tools.resolve("tinymce.Env"),C=A.mac?"\u2318":"Ctrl",S=A.mac?"Ctrl + Alt":"Shift + Alt",O={shortcuts:[{shortcut:C+" + B",action:"Bold"},{shortcut:C+" + I",action:"Italic"},{shortcut:C+" + U",action:"Underline"},{shortcut:C+" + A",action:"Select all"},{shortcut:C+" + Y or "+C+" + Shift + Z",action:"Redo"},{shortcut:C+" + Z",action:"Undo"},{shortcut:S+" + 1",action:"Header 1"},{shortcut:S+" + 2",action:"Header 2"},{shortcut:S+" + 3",action:"Header 3"},{shortcut:S+" + 4",action:"Header 4"},{shortcut:S+" + 5",action:"Header 5"},{shortcut:S+" + 6",action:"Header 6"},{shortcut:S+" + 7",action:"Paragraph"},{shortcut:S+" + 8",action:"Div"},{shortcut:S+" + 9",action:"Address"},{shortcut:"Alt + F9",action:"Focus to menubar"},{shortcut:"Alt + F10",action:"Focus to toolbar"},{shortcut:"Alt + F11",action:"Focus to element path"},{shortcut:"Ctrl + F9",action:"Focus to contextual toolbar"},{shortcut:C+" + K",action:"Insert link (if link plugin activated)"},{shortcut:C+" + S",action:"Save (if save plugin activated)"},{shortcut:C+" + F",action:"Find (if searchreplace plugin activated)"}]},T=function(){var e=b(O.shortcuts,function(e){return'<tr data-mce-tabstop="1" tabindex="-1" aria-label="Action: '+(t=e).action+", Shortcut: "+t.shortcut.replace(/Ctrl/g,"Control")+'"><td>'+w.translate(e.action)+"</td><td>"+e.shortcut+"</td></tr>";var t}).join("");return{title:"Handy Shortcuts",type:"container",style:"overflow-y: auto; overflow-x: hidden; max-height: 250px",items:[{type:"container",html:'<div><table class="mce-table-striped"><thead><th>'+w.translate("Action")+"</th><th>"+w.translate("Shortcut")+"</th></thead>"+e+"</table></div>"}]}},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})},'<a href="${url}" target="_blank" rel="noopener">${name}</a>'),F=function(t,n){return function(e,t){for(var n=0,r=e.length;n<r;n++){var o=e[n];if(t(o,n,e))return y.some(o)}return y.none()}(_,function(e){return e.key===n}).fold(function(){var e=t.plugins[n].getMetadata;return"function"==typeof e?H(e()):n},function(e){return H({name:e.name,url:"https://www.tinymce.com/docs/plugins/"+e.key})})},M=function(t){var e,n,r,o=(r=P((e=t).plugins),e.settings.forced_plugins===undefined?r:function(e,t){for(var n=[],r=0,o=e.length;r<o;r++){var a=e[r];t(a,r,e)&&n.push(a)}return n}(r,(n=c(v,e.settings.forced_plugins),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return!n.apply(null,arguments)}))),a=b(o,function(e){return"<li>"+F(t,e)+"</li>"}),i=a.length,l=a.join("");return"<p><b>"+w.translate(["Plugins installed ({0}):",i])+"</b></p><ul>"+l+"</ul>"},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:'<div style="overflow-y: auto; overflow-x: hidden; max-height: 230px; height: 230px;" data-mce-tabstop="1" tabindex="-1">'+M(t)+"</div>",flex:1}),{type:"container",html:'<div style="padding: 10px; background: #e3e7f4; height: 100%;" data-mce-tabstop="1" tabindex="-1"><p><b>'+w.translate("Premium plugins:")+'</b></p><ul><li>PowerPaste</li><li>Spell Checker Pro</li><li>Accessibility Checker</li><li>Advanced Code Editor</li><li>Enhanced Media Embed</li><li>Link Checker</li></ul><br /><p style="float: right;"><a href="https://www.tinymce.com/pricing/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" target="_blank">'+w.translate("Learn more...")+"</a></p></div>",flex:1}]};var t},I=tinymce.util.Tools.resolve("tinymce.EditorManager"),j=function(){var e,t,n='<a href="https://www.tinymce.com/docs/changelog/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" target="_blank">TinyMCE '+(e=I.majorVersion,t=I.minorVersion,0===e.indexOf("@")?"X.X.X":e+"."+t)+"</a>";return[{type:"label",html:w.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='<img src="'+t+'/img/logo.png" alt="TinyMCE Logo" style="display: inline-block; width: 200px; height: 50px">'}})}},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)})};i.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(e){return function(){return e}};function c(r){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=o.concat(e);return r.apply(null,n)}}var n,r,o,a,i,l,u=t(!1),s=t(!0),m=u,f=s,d=function(){return p},p=(a={fold:function(e,t){return e()},is:m,isSome:m,isNone:f,getOr:o=function(e){return e},getOrThunk:r=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:o,orThunk:r,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:m,forall:f,filter:d,equals:n=function(e){return e.isNone()},equals_:n,toArray:function(){return[]},toString:t("none()")},Object.freeze&&Object.freeze(a),a),y=function(n){var e=function(){return n},t=function(){return o},r=function(e){return e(n)},o={fold:function(e,t){return t(n)},is:function(e){return n===e},isSome:f,isNone:m,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return y(e(n))},ap:function(e){return e.fold(d,function(e){return y(e(n))})},each:function(e){e(n)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(n)?o:p},equals:function(e){return e.is(n)},equals_:function(e,t){return e.fold(m,function(e){return t(n,e)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},h={some:y,none:d,from:function(e){return null===e||e===undefined?p:y(e)}},g=(i="function",function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&Array.prototype.isPrototypeOf(e)?"array":"object"===t&&String.prototype.isPrototypeOf(e)?"string":t}(e)===i}),k=(l=Array.prototype.indexOf)===undefined?function(e,t){return x(e,t)}:function(e,t){return l.call(e,t)},v=function(e,t){return-1<k(e,t)},b=function(e,t){for(var n=e.length,r=new Array(n),o=0;o<n;o++){var a=e[o];r[o]=t(a,o,e)}return r},x=function(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return n;return-1},C=(Array.prototype.slice,g(Array.from)&&Array.from,tinymce.util.Tools.resolve("tinymce.util.I18n")),w=tinymce.util.Tools.resolve("tinymce.Env"),A=w.mac?"\u2318":"Ctrl",S=w.mac?"Ctrl + Alt":"Shift + Alt",O={shortcuts:[{shortcut:A+" + B",action:"Bold"},{shortcut:A+" + I",action:"Italic"},{shortcut:A+" + U",action:"Underline"},{shortcut:A+" + A",action:"Select all"},{shortcut:A+" + Y or "+A+" + Shift + Z",action:"Redo"},{shortcut:A+" + Z",action:"Undo"},{shortcut:S+" + 1",action:"Header 1"},{shortcut:S+" + 2",action:"Header 2"},{shortcut:S+" + 3",action:"Header 3"},{shortcut:S+" + 4",action:"Header 4"},{shortcut:S+" + 5",action:"Header 5"},{shortcut:S+" + 6",action:"Header 6"},{shortcut:S+" + 7",action:"Paragraph"},{shortcut:S+" + 8",action:"Div"},{shortcut:S+" + 9",action:"Address"},{shortcut:"Alt + F9",action:"Focus to menubar"},{shortcut:"Alt + F10",action:"Focus to toolbar"},{shortcut:"Alt + F11",action:"Focus to element path"},{shortcut:"Ctrl + F9",action:"Focus to contextual toolbar"},{shortcut:A+" + K",action:"Insert link (if link plugin activated)"},{shortcut:A+" + S",action:"Save (if save plugin activated)"},{shortcut:A+" + F",action:"Find (if searchreplace plugin activated)"}]},T=function(){var e=b(O.shortcuts,function(e){return'<tr data-mce-tabstop="1" tabindex="-1" aria-label="Action: '+(t=e).action+", Shortcut: "+t.shortcut.replace(/Ctrl/g,"Control")+'"><td>'+C.translate(e.action)+"</td><td>"+e.shortcut+"</td></tr>";var t}).join("");return{title:"Handy Shortcuts",type:"container",style:"overflow-y: auto; overflow-x: hidden; max-height: 250px",items:[{type:"container",html:'<div><table class="mce-table-striped"><thead><th>'+C.translate("Action")+"</th><th>"+C.translate("Shortcut")+"</th></thead>"+e+"</table></div>"}]}},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})},'<a href="${url}" target="_blank" rel="noopener">${name}</a>'),F=function(t,n){return function(e,t){for(var n=0,r=e.length;n<r;n++){var o=e[n];if(t(o,n,e))return h.some(o)}return h.none()}(_,function(e){return e.key===n}).fold(function(){var e=t.plugins[n].getMetadata;return"function"==typeof e?H(e()):n},function(e){return H({name:e.name,url:"https://www.tinymce.com/docs/plugins/"+e.key})})},M=function(t){var e,n,r,o=(r=P((e=t).plugins),e.settings.forced_plugins===undefined?r:function(e,t){for(var n=[],r=0,o=e.length;r<o;r++){var a=e[r];t(a,r,e)&&n.push(a)}return n}(r,(n=c(v,e.settings.forced_plugins),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return!n.apply(null,e)}))),a=b(o,function(e){return"<li>"+F(t,e)+"</li>"}),i=a.length,l=a.join("");return"<p><b>"+C.translate(["Plugins installed ({0}):",i])+"</b></p><ul>"+l+"</ul>"},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:'<div style="overflow-y: auto; overflow-x: hidden; max-height: 230px; height: 230px;" data-mce-tabstop="1" tabindex="-1">'+M(t)+"</div>",flex:1}),{type:"container",html:'<div style="padding: 10px; background: #e3e7f4; height: 100%;" data-mce-tabstop="1" tabindex="-1"><p><b>'+C.translate("Premium plugins:")+'</b></p><ul><li>PowerPaste</li><li>Spell Checker Pro</li><li>Accessibility Checker</li><li>Advanced Code Editor</li><li>Enhanced Media Embed</li><li>Link Checker</li></ul><br /><p style="float: right;"><a href="https://www.tinymce.com/pricing/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" target="_blank">'+C.translate("Learn more...")+"</a></p></div>",flex:1}]};var t},I=tinymce.util.Tools.resolve("tinymce.EditorManager"),j=function(){var e,t,n='<a href="https://www.tinymce.com/docs/changelog/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" target="_blank">TinyMCE '+(e=I.majorVersion,t=I.minorVersion,0===e.indexOf("@")?"X.X.X":e+"."+t)+"</a>";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='<img src="'+t+'/img/logo.png" alt="TinyMCE Logo" style="display: inline-block; width: 200px; height: 50px">'}})}},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

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,7 +63,7 @@
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;
@@ -102,7 +102,7 @@
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 +125,7 @@
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) {
@@ -294,21 +294,21 @@
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 +339,21 @@
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 +396,7 @@
};
};
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 +413,7 @@
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 +442,13 @@
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 +952,7 @@
}
success(pathJoin(settings.basePath, json.location));
};
- formData = new FormData();
+ formData = new domGlobals.FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());
xhr.send(formData);
};
@@ -1058,26 +1058,20 @@
};
var UploadTab = { makeTab: makeTab$2 };
- var curry = function (f) {
- var x = [];
+ function curry(fn) {
+ var initialArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
- x[_i - 1] = arguments[_i];
+ initialArgs[_i - 1] = arguments[_i];
}
- var args = new Array(arguments.length - 1);
- for (var i = 1; i < arguments.length; i++)
- args[i - 1] = arguments[i];
return function () {
- var x = [];
+ var restArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ restArgs[_i] = arguments[_i];
}
- var newArgs = new Array(arguments.length);
- for (var j = 0; j < newArgs.length; j++)
- newArgs[j] = arguments[j];
- var all = args.concat(newArgs);
- return f.apply(null, all);
- };
+ var all = initialArgs.concat(restArgs);
+ return fn.apply(null, all);
};
+ }
var submitForm = function (editor, evt) {
var win = evt.control.getRoot();
@@ -1206,5 +1200,5 @@
return Plugin;
-}());
+}(window));
})();

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},g=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)},m=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<e.length&&n!==undefined&&null!==n;++r)n=n[e[r]];return n}(e.split("."),t)},y={getOrDie:function(e,t){var n=b(e,t);if(n===undefined||null===n)throw e+" not available on this browser";return n}},x=tinymce.util.Tools.resolve("tinymce.util.Promise"),w=tinymce.util.Tools.resolve("tinymce.util.Tools"),C=tinymce.util.Tools.resolve("tinymce.util.XHR"),S=function(e,t){return Math.max(parseInt(e,10),parseInt(t,10))},N=function(e,n){var r=document.createElement("img");function t(e,t){r.parentNode&&r.parentNode.removeChild(r),n({width:e,height:t})}r.onload=function(){t(S(r.width,r.clientWidth),S(r.height,r.clientHeight))},r.onerror=function(){t(0,0)};var a=r.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left="0px",a.width=a.height="auto",document.body.appendChild(r),r.src=e},_=function(e,a,t){return function n(e,r){return r=r||[],w.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=n(e.menu):(t.value=e.value,a(t)),r.push(t)}),r}(e,t||[])},A=function(e){return e&&(e=e.replace(/px$/,"")),e},T=function(e){return 0<e.length&&/^[0-9]+$/.test(e)&&(e+="px"),e},R=function(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e},t=function(e,t){var n=u(e);"string"==typeof n?C.send({url:n,success:function(e){t(JSON.parse(e))}}):"function"==typeof n?n(t):t(n)},I=function(e,t,n){function r(){n.onload=n.onerror=null,e.selection&&(e.selection.select(n),e.nodeChanged())}n.onload=function(){t.width||t.height||!d(e)||e.dom.setAttribs(n,{width:n.clientWidth,height:n.clientHeight}),r()},n.onerror=r},O=function(r){return new x(function(e,t){var n=new(y.getOrDie("FileReader"));n.onload=function(){e(n.result)},n.onerror=function(){t(n.error.message)},n.readAsDataURL(r)})},L=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),P=Object.prototype.hasOwnProperty,U=(i=function(e,t){return t},function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var a=e[r];for(var o in a)P.call(a,o)&&(n[o]=i(n[o],a[o]))}return n}),E=L.DOM,k=function(e){return e.style.marginLeft&&e.style.marginRight&&e.style.marginLeft===e.style.marginRight?A(e.style.marginLeft):""},M=function(e){return e.style.marginTop&&e.style.marginBottom&&e.style.marginTop===e.style.marginBottom?A(e.style.marginTop):""},D=function(e){return e.style.borderWidth?A(e.style.borderWidth):""},z=function(e,t){return e.hasAttribute(t)?e.getAttribute(t):""},B=function(e,t){return e.style[t]?e.style[t]:""},H=function(e){return null!==e.parentNode&&"FIGURE"===e.parentNode.nodeName},j=function(e,t,n){e.setAttribute(t,n)},F=function(e){var t,n,r,a;H(e)?(a=(r=e).parentNode,E.insertAfter(r,a),E.remove(a)):(t=e,n=E.create("figure",{"class":"image"}),E.insertAfter(n,t),n.appendChild(t),n.appendChild(E.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable="false")},W=function(e,t){var n=e.getAttribute("style"),r=t(null!==n?n:"");0<r.length?(e.setAttribute("style",r),e.setAttribute("data-mce-style",r)):e.removeAttribute("style")},J=function(e,r){return function(e,t,n){e.style[t]?(e.style[t]=T(n),W(e,r)):j(e,t,n)}},V=function(e,t){return e.style[t]?A(e.style[t]):z(e,t)},G=function(e,t){var n=T(t);e.style.marginLeft=n,e.style.marginRight=n},$=function(e,t){var n=T(t);e.style.marginTop=n,e.style.marginBottom=n},X=function(e,t){var n=T(t);e.style.borderWidth=n},q=function(e,t){e.style.borderStyle=t},K=function(e){return"FIGURE"===e.nodeName},Q=function(e,t){var n=document.createElement("img");return j(n,"style",t.style),(k(n)||""!==t.hspace)&&G(n,t.hspace),(M(n)||""!==t.vspace)&&$(n,t.vspace),(D(n)||""!==t.border)&&X(n,t.border),(B(n,"borderStyle")||""!==t.borderStyle)&&q(n,t.borderStyle),e(n.getAttribute("style"))},Y=function(e,t){return{src:z(t,"src"),alt:z(t,"alt"),title:z(t,"title"),width:V(t,"width"),height:V(t,"height"),"class":z(t,"class"),style:e(z(t,"style")),caption:H(t),hspace:k(t),vspace:M(t),border:D(t),borderStyle:B(t,"borderStyle")}},Z=function(e,t,n,r,a){n[r]!==t[r]&&a(e,r,n[r])},ee=function(r,a){return function(e,t,n){r(e,n),W(e,a)}},te=function(e,t,n){var r=Y(e,n);Z(n,r,t,"caption",function(e,t,n){return F(e)}),Z(n,r,t,"src",j),Z(n,r,t,"alt",j),Z(n,r,t,"title",j),Z(n,r,t,"width",J(0,e)),Z(n,r,t,"height",J(0,e)),Z(n,r,t,"class",j),Z(n,r,t,"style",ee(function(e,t){return j(e,"style",t)},e)),Z(n,r,t,"hspace",ee(G,e)),Z(n,r,t,"vspace",ee($,e)),Z(n,r,t,"border",ee(X,e)),Z(n,r,t,"borderStyle",ee(q,e))},ne=function(e,t){var n=e.dom.styles.parse(t),r=R(n),a=e.dom.styles.parse(e.dom.styles.serialize(r));return e.dom.styles.serialize(a)},re=function(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"figure.image");return n?e.dom.select("img",n)[0]:t&&("IMG"!==t.nodeName||t.getAttribute("data-mce-object")||t.getAttribute("data-mce-placeholder"))?null:t},ae=function(t,e){var n=t.dom,r=n.getParent(e.parentNode,function(e){return t.schema.getTextBlockElements()[e.nodeName]},t.getBody());return r?n.split(r,e):e},oe=function(t){var e=re(t);return e?Y(function(e){return ne(t,e)},e):{src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""}},ie=function(t,e){var n=function(e,t){var n=document.createElement("img");if(te(e,U(t,{caption:!1}),n),j(n,"alt",t.alt),t.caption){var r=E.create("figure",{"class":"image"});return r.appendChild(n),r.appendChild(E.create("figcaption",{contentEditable:!0},"Caption")),r.contentEditable="false",r}return n}(function(e){return ne(t,e)},e);t.dom.setAttrib(n,"data-mce-id","__mcenew"),t.focus(),t.selection.setContent(n.outerHTML);var r=t.dom.select('*[data-mce-id="__mcenew"]')[0];if(t.dom.setAttrib(r,"data-mce-id",null),K(r)){var a=ae(t,r);t.selection.select(a)}else t.selection.select(r)},le=function(e,t){var n=re(e);n?t.src?function(t,e){var n,r=re(t);if(te(function(e){return ne(t,e)},e,r),n=r,t.dom.setAttrib(n,"src",n.getAttribute("src")),K(r.parentNode)){var a=r.parentNode;ae(t,a),t.selection.select(r.parentNode)}else t.selection.select(r),I(t,e,r)}(e,t):function(e,t){if(t){var n=e.dom.is(t.parentNode,"figure.image")?t.parentNode:t;e.dom.remove(n),e.focus(),e.nodeChanged(),e.dom.isEmpty(e.getBody())&&(e.setContent(""),e.selection.setCursorLocation())}}(e,n):t.src&&ie(e,t)},ue=function(n,r){r.find("#style").each(function(e){var t=Q(function(e){return ne(n,e)},U({src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""},r.toJSON()));e.value(t)})},ce=function(t){return{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:(o=t,function(e){var t=o.dom,n=e.control.rootControl;if(l(o)){var r=n.toJSON(),a=t.parseStyle(r.style);n.find("#vspace").value(""),n.find("#hspace").value(""),((a=R(a))["margin-top"]&&a["margin-bottom"]||a["margin-right"]&&a["margin-left"])&&(a["margin-top"]===a["margin-bottom"]?n.find("#vspace").value(A(a["margin-top"])):n.find("#vspace").value(""),a["margin-right"]===a["margin-left"]?n.find("#hspace").value(A(a["margin-right"])):n.find("#hspace").value("")),a["border-width"]?n.find("#border").value(A(a["border-width"])):n.find("#border").value(""),a["border-style"]?n.find("#borderStyle").value(a["border-style"]):n.find("#borderStyle").value(""),n.find("#style").value(t.serializeStyle(t.parseStyle(t.serializeStyle(a))))}})},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,defaults:{type:"textbox",maxWidth:50,onchange:function(e){ue(t,e.control.rootControl)}},items:[{label:"Vertical space",name:"vspace"},{label:"Border width",name:"border"},{label:"Horizontal space",name:"hspace"},{label:"Border style",type:"listbox",name:"borderStyle",width:90,maxWidth:90,onselect:function(e){ue(t,e.control.rootControl)},values:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]};var o},se=function(e,t){e.state.set("oldVal",e.value()),t.state.set("oldVal",t.value())},de=function(e,t){var n=e.find("#width")[0],r=e.find("#height")[0],a=e.find("#constrain")[0];n&&r&&a&&t(n,r,a.checked())},ge=function(e,t,n){var r=e.state.get("oldVal"),a=t.state.get("oldVal"),o=e.value(),i=t.value();n&&r&&a&&o&&i&&(o!==r?(i=Math.round(o/r*i),isNaN(i)||t.value(i)):(o=Math.round(i/a*o),isNaN(o)||e.value(o))),se(e,t)},me=function(e){de(e,ge)},fe=function(){var e=function(e){me(e.control.rootControl)};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}},pe=function(e){de(e,se)},he=me,ve=function(e){e.meta=e.control.rootControl.toJSON()},be=function(s,e){var t=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:function(e){var t,n,r,a,o,i,l,u,c;n=s,i=(t=e).meta||{},l=t.control,u=l.rootControl,(c=u.find("#image-list")[0])&&c.value(n.convertURL(l.value(),"src")),w.each(i,function(e,t){u.find("#"+t).value(e)}),i.width||i.height||(r=n.convertURL(l.value(),"src"),a=g(n),o=new RegExp("^(?:[a-z]+:)?//","i"),a&&!o.test(r)&&r.substring(0,a.length)!==a&&(r=a+r),l.value(r),N(n.documentBaseURI.toAbsolute(l.value()),function(e){e.width&&e.height&&d(n)&&(u.find("#width").value(e.width),u.find("#height").value(e.height),pe(u))}))},onbeforecall:ve},e];return r(s)&&t.push({name:"alt",type:"textbox",label:"Image description"}),a(s)&&t.push({name:"title",type:"textbox",label:"Image Title"}),d(s)&&t.push(fe()),n(s)&&t.push({name:"class",type:"listbox",label:"Class",values:_(n(s),function(e){e.value&&(e.textStyle=function(){return s.formatter.getCssText({inline:"img",classes:[e.value]})})})}),o(s)&&t.push({name:"caption",type:"checkbox",label:"Caption"}),t},ye=function(e,t){return{title:"General",type:"form",items:be(e,t)}},xe=be,we=function(){return y.getOrDie("URL")},Ce=function(e){return we().createObjectURL(e)},Se=function(e){we().revokeObjectURL(e)},Ne=tinymce.util.Tools.resolve("tinymce.ui.Factory"),_e=function(){};function Ae(i){var t=function(e,r,a,t){var o,n;(o=new(y.getOrDie("XMLHttpRequest"))).open("POST",i.url),o.withCredentials=i.credentials,o.upload.onprogress=function(e){t(e.loaded/e.total*100)},o.onerror=function(){a("Image upload failed due to a XHR Transport error. Code: "+o.status)},o.onload=function(){var e,t,n;o.status<200||300<=o.status?a("HTTP Error: "+o.status):(e=JSON.parse(o.responseText))&&"string"==typeof e.location?r((t=i.basePath,n=e.location,t?t.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):a("Invalid JSON: "+o.responseText)},(n=new FormData).append("file",e.blob(),e.filename()),o.send(n)};return i=w.extend({credentials:!1,handler:t},i),{upload:function(e){return i.url||i.handler!==t?(r=e,a=i.handler,new x(function(e,t){try{a(r,e,t,_e)}catch(n){t(n.message)}})):x.reject("Upload url missing from the settings.");var r,a}}}var Te=function(u){return function(e){var t=Ne.get("Throbber"),n=e.control.rootControl,r=new t(n.getEl()),a=e.control.value(),o=Ce(a),i=Ae({url:m(u),basePath:p(u),credentials:h(u),handler:f(u)}),l=function(){r.hide(),Se(o)};return r.show(),O(a).then(function(e){var t=u.editorUpload.blobCache.create({blob:a,blobUri:o,name:a.name?a.name.replace(/\.[^\.]+$/,""):null,base64:e.split(",")[1]});return i.upload(t).then(function(e){var t=n.find("#src");return t.value(e),n.find("tabpanel")[0].activateTab(0),t.fire("change"),l(),e})})["catch"](function(e){u.windowManager.alert(e),l()})}},Re=".jpg,.jpeg,.png,.gif",Ie=function(e){return{title:"Upload",type:"form",layout:"flex",direction:"column",align:"stretch",padding:"20 20 20 20",items:[{type:"container",layout:"flex",direction:"column",align:"center",spacing:10,items:[{text:"Browse for an image",type:"browsebutton",accept:Re,onchange:Te(e)},{text:"OR",type:"label"}]},{text:"Drop an image here",type:"dropzone",accept:Re,height:100,onchange:Te(e)}]}},Oe=function(o){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var i=new Array(arguments.length-1),n=1;n<arguments.length;n++)i[n-1]=arguments[n];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var a=i.concat(n);return o.apply(null,a)}},Le=function(t,e){var n=e.control.getRoot();he(n),t.undoManager.transact(function(){var e=U(oe(t),n.toJSON());le(t,e)}),t.editorUpload.uploadImagesAuto()};function Pe(o){function e(e){var n,t,r=oe(o);if(e&&(t={type:"listbox",label:"Image list",name:"image-list",values:_(e,function(e){e.value=o.convertURL(e.value||e.url,"src")},[{text:"None",value:""}]),value:r.src&&o.convertURL(r.src,"src"),onselect:function(e){var t=n.find("#alt");(!t.value()||e.lastControl&&t.value()===e.lastControl.text())&&t.value(e.control.text()),n.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){t=this}}),l(o)||c(o)||s(o)){var a=[ye(o,t)];l(o)&&a.push(ce(o)),(c(o)||s(o))&&a.push(Ie(o)),n=o.windowManager.open({title:"Insert/edit image",data:r,bodyType:"tabpanel",body:a,onSubmit:Oe(Le,o)})}else n=o.windowManager.open({title:"Insert/edit image",data:r,body:xe(o,t),onSubmit:Oe(Le,o)});pe(n)}return{open:function(){t(o,e)}}}var Ue=function(e){e.addCommand("mceImage",Pe(e).open)},Ee=function(o){return function(e){for(var t,n,r=e.length,a=function(e){e.attr("contenteditable",o?"true":null)};r--;)t=e[r],(n=t.attr("class"))&&/\bimage\b/.test(n)&&(t.attr("contenteditable",o?"false":null),w.each(t.getAll("figcaption"),a))}},ke=function(e){e.on("preInit",function(){e.parser.addNodeFilter("figure",Ee(!0)),e.serializer.addNodeFilter("figure",Ee(!1))})},Me=function(e){e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:Pe(e).open,stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:Pe(e).open,context:"insert",prependToContext:!0})};e.add("image",function(e){ke(e),Me(e),Ue(e)})}();
\ No newline at end of file
+!function(l){"use strict";var i,e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=function(e){return!1!==e.settings.image_dimensions},u=function(e){return!0===e.settings.image_advtab},m=function(e){return e.getParam("image_prepend_url","")},n=function(e){return e.getParam("image_class_list")},r=function(e){return!1!==e.settings.image_description},a=function(e){return!0===e.settings.image_title},o=function(e){return!0===e.settings.image_caption},c=function(e){return e.getParam("image_list",!1)},s=function(e){return e.getParam("images_upload_url",!1)},g=function(e){return e.getParam("images_upload_handler",!1)},f=function(e){return e.getParam("images_upload_url")},p=function(e){return e.getParam("images_upload_handler")},h=function(e){return e.getParam("images_upload_base_path")},v=function(e){return e.getParam("images_upload_credentials")},b="undefined"!=typeof l.window?l.window:Function("return this;")(),y=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:b,r=0;r<e.length&&n!==undefined&&null!==n;++r)n=n[e[r]];return n}(e.split("."),t)},x={getOrDie:function(e,t){var n=y(e,t);if(n===undefined||null===n)throw e+" not available on this browser";return n}},w=tinymce.util.Tools.resolve("tinymce.util.Promise"),C=tinymce.util.Tools.resolve("tinymce.util.Tools"),S=tinymce.util.Tools.resolve("tinymce.util.XHR"),N=function(e,t){return Math.max(parseInt(e,10),parseInt(t,10))},_=function(e,n){var r=l.document.createElement("img");function t(e,t){r.parentNode&&r.parentNode.removeChild(r),n({width:e,height:t})}r.onload=function(){t(N(r.width,r.clientWidth),N(r.height,r.clientHeight))},r.onerror=function(){t(0,0)};var a=r.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left="0px",a.width=a.height="auto",l.document.body.appendChild(r),r.src=e},T=function(e,a,t){return function n(e,r){return r=r||[],C.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=n(e.menu):(t.value=e.value,a(t)),r.push(t)}),r}(e,t||[])},A=function(e){return e&&(e=e.replace(/px$/,"")),e},R=function(e){return 0<e.length&&/^[0-9]+$/.test(e)&&(e+="px"),e},I=function(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e},t=function(e,t){var n=c(e);"string"==typeof n?S.send({url:n,success:function(e){t(JSON.parse(e))}}):"function"==typeof n?n(t):t(n)},O=function(e,t,n){function r(){n.onload=n.onerror=null,e.selection&&(e.selection.select(n),e.nodeChanged())}n.onload=function(){t.width||t.height||!d(e)||e.dom.setAttribs(n,{width:n.clientWidth,height:n.clientHeight}),r()},n.onerror=r},L=function(r){return new w(function(e,t){var n=new(x.getOrDie("FileReader"));n.onload=function(){e(n.result)},n.onerror=function(){t(n.error.message)},n.readAsDataURL(r)})},P=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),U=Object.prototype.hasOwnProperty,E=(i=function(e,t){return t},function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var a=e[r];for(var o in a)U.call(a,o)&&(n[o]=i(n[o],a[o]))}return n}),k=P.DOM,M=function(e){return e.style.marginLeft&&e.style.marginRight&&e.style.marginLeft===e.style.marginRight?A(e.style.marginLeft):""},D=function(e){return e.style.marginTop&&e.style.marginBottom&&e.style.marginTop===e.style.marginBottom?A(e.style.marginTop):""},z=function(e){return e.style.borderWidth?A(e.style.borderWidth):""},B=function(e,t){return e.hasAttribute(t)?e.getAttribute(t):""},H=function(e,t){return e.style[t]?e.style[t]:""},j=function(e){return null!==e.parentNode&&"FIGURE"===e.parentNode.nodeName},F=function(e,t,n){e.setAttribute(t,n)},W=function(e){var t,n,r,a;j(e)?(a=(r=e).parentNode,k.insertAfter(r,a),k.remove(a)):(t=e,n=k.create("figure",{"class":"image"}),k.insertAfter(n,t),n.appendChild(t),n.appendChild(k.create("figcaption",{contentEditable:!0},"Caption")),n.contentEditable="false")},J=function(e,t){var n=e.getAttribute("style"),r=t(null!==n?n:"");0<r.length?(e.setAttribute("style",r),e.setAttribute("data-mce-style",r)):e.removeAttribute("style")},V=function(e,r){return function(e,t,n){e.style[t]?(e.style[t]=R(n),J(e,r)):F(e,t,n)}},G=function(e,t){return e.style[t]?A(e.style[t]):B(e,t)},$=function(e,t){var n=R(t);e.style.marginLeft=n,e.style.marginRight=n},X=function(e,t){var n=R(t);e.style.marginTop=n,e.style.marginBottom=n},q=function(e,t){var n=R(t);e.style.borderWidth=n},K=function(e,t){e.style.borderStyle=t},Q=function(e){return"FIGURE"===e.nodeName},Y=function(e,t){var n=l.document.createElement("img");return F(n,"style",t.style),(M(n)||""!==t.hspace)&&$(n,t.hspace),(D(n)||""!==t.vspace)&&X(n,t.vspace),(z(n)||""!==t.border)&&q(n,t.border),(H(n,"borderStyle")||""!==t.borderStyle)&&K(n,t.borderStyle),e(n.getAttribute("style"))},Z=function(e,t){return{src:B(t,"src"),alt:B(t,"alt"),title:B(t,"title"),width:G(t,"width"),height:G(t,"height"),"class":B(t,"class"),style:e(B(t,"style")),caption:j(t),hspace:M(t),vspace:D(t),border:z(t),borderStyle:H(t,"borderStyle")}},ee=function(e,t,n,r,a){n[r]!==t[r]&&a(e,r,n[r])},te=function(r,a){return function(e,t,n){r(e,n),J(e,a)}},ne=function(e,t,n){var r=Z(e,n);ee(n,r,t,"caption",function(e,t,n){return W(e)}),ee(n,r,t,"src",F),ee(n,r,t,"alt",F),ee(n,r,t,"title",F),ee(n,r,t,"width",V(0,e)),ee(n,r,t,"height",V(0,e)),ee(n,r,t,"class",F),ee(n,r,t,"style",te(function(e,t){return F(e,"style",t)},e)),ee(n,r,t,"hspace",te($,e)),ee(n,r,t,"vspace",te(X,e)),ee(n,r,t,"border",te(q,e)),ee(n,r,t,"borderStyle",te(K,e))},re=function(e,t){var n=e.dom.styles.parse(t),r=I(n),a=e.dom.styles.parse(e.dom.styles.serialize(r));return e.dom.styles.serialize(a)},ae=function(e){var t=e.selection.getNode(),n=e.dom.getParent(t,"figure.image");return n?e.dom.select("img",n)[0]:t&&("IMG"!==t.nodeName||t.getAttribute("data-mce-object")||t.getAttribute("data-mce-placeholder"))?null:t},oe=function(t,e){var n=t.dom,r=n.getParent(e.parentNode,function(e){return t.schema.getTextBlockElements()[e.nodeName]},t.getBody());return r?n.split(r,e):e},ie=function(t){var e=ae(t);return e?Z(function(e){return re(t,e)},e):{src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""}},le=function(t,e){var n=function(e,t){var n=l.document.createElement("img");if(ne(e,E(t,{caption:!1}),n),F(n,"alt",t.alt),t.caption){var r=k.create("figure",{"class":"image"});return r.appendChild(n),r.appendChild(k.create("figcaption",{contentEditable:!0},"Caption")),r.contentEditable="false",r}return n}(function(e){return re(t,e)},e);t.dom.setAttrib(n,"data-mce-id","__mcenew"),t.focus(),t.selection.setContent(n.outerHTML);var r=t.dom.select('*[data-mce-id="__mcenew"]')[0];if(t.dom.setAttrib(r,"data-mce-id",null),Q(r)){var a=oe(t,r);t.selection.select(a)}else t.selection.select(r)},ue=function(e,t){var n=ae(e);n?t.src?function(t,e){var n,r=ae(t);if(ne(function(e){return re(t,e)},e,r),n=r,t.dom.setAttrib(n,"src",n.getAttribute("src")),Q(r.parentNode)){var a=r.parentNode;oe(t,a),t.selection.select(r.parentNode)}else t.selection.select(r),O(t,e,r)}(e,t):function(e,t){if(t){var n=e.dom.is(t.parentNode,"figure.image")?t.parentNode:t;e.dom.remove(n),e.focus(),e.nodeChanged(),e.dom.isEmpty(e.getBody())&&(e.setContent(""),e.selection.setCursorLocation())}}(e,n):t.src&&le(e,t)},ce=function(n,r){r.find("#style").each(function(e){var t=Y(function(e){return re(n,e)},E({src:"",alt:"",title:"",width:"",height:"","class":"",style:"",caption:!1,hspace:"",vspace:"",border:"",borderStyle:""},r.toJSON()));e.value(t)})},se=function(t){return{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:(o=t,function(e){var t=o.dom,n=e.control.rootControl;if(u(o)){var r=n.toJSON(),a=t.parseStyle(r.style);n.find("#vspace").value(""),n.find("#hspace").value(""),((a=I(a))["margin-top"]&&a["margin-bottom"]||a["margin-right"]&&a["margin-left"])&&(a["margin-top"]===a["margin-bottom"]?n.find("#vspace").value(A(a["margin-top"])):n.find("#vspace").value(""),a["margin-right"]===a["margin-left"]?n.find("#hspace").value(A(a["margin-right"])):n.find("#hspace").value("")),a["border-width"]?n.find("#border").value(A(a["border-width"])):n.find("#border").value(""),a["border-style"]?n.find("#borderStyle").value(a["border-style"]):n.find("#borderStyle").value(""),n.find("#style").value(t.serializeStyle(t.parseStyle(t.serializeStyle(a))))}})},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,defaults:{type:"textbox",maxWidth:50,onchange:function(e){ce(t,e.control.rootControl)}},items:[{label:"Vertical space",name:"vspace"},{label:"Border width",name:"border"},{label:"Horizontal space",name:"hspace"},{label:"Border style",type:"listbox",name:"borderStyle",width:90,maxWidth:90,onselect:function(e){ce(t,e.control.rootControl)},values:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]}]}]};var o},de=function(e,t){e.state.set("oldVal",e.value()),t.state.set("oldVal",t.value())},me=function(e,t){var n=e.find("#width")[0],r=e.find("#height")[0],a=e.find("#constrain")[0];n&&r&&a&&t(n,r,a.checked())},ge=function(e,t,n){var r=e.state.get("oldVal"),a=t.state.get("oldVal"),o=e.value(),i=t.value();n&&r&&a&&o&&i&&(o!==r?(i=Math.round(o/r*i),isNaN(i)||t.value(i)):(o=Math.round(i/a*o),isNaN(o)||e.value(o))),de(e,t)},fe=function(e){me(e,ge)},pe=function(){var e=function(e){fe(e.control.rootControl)};return{type:"container",label:"Dimensions",layout:"flex",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:5,onchange:e,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}},he=function(e){me(e,de)},ve=fe,be=function(e){e.meta=e.control.rootControl.toJSON()},ye=function(s,e){var t=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:function(e){var t,n,r,a,o,i,l,u,c;n=s,i=(t=e).meta||{},l=t.control,u=l.rootControl,(c=u.find("#image-list")[0])&&c.value(n.convertURL(l.value(),"src")),C.each(i,function(e,t){u.find("#"+t).value(e)}),i.width||i.height||(r=n.convertURL(l.value(),"src"),a=m(n),o=new RegExp("^(?:[a-z]+:)?//","i"),a&&!o.test(r)&&r.substring(0,a.length)!==a&&(r=a+r),l.value(r),_(n.documentBaseURI.toAbsolute(l.value()),function(e){e.width&&e.height&&d(n)&&(u.find("#width").value(e.width),u.find("#height").value(e.height),he(u))}))},onbeforecall:be},e];return r(s)&&t.push({name:"alt",type:"textbox",label:"Image description"}),a(s)&&t.push({name:"title",type:"textbox",label:"Image Title"}),d(s)&&t.push(pe()),n(s)&&t.push({name:"class",type:"listbox",label:"Class",values:T(n(s),function(e){e.value&&(e.textStyle=function(){return s.formatter.getCssText({inline:"img",classes:[e.value]})})})}),o(s)&&t.push({name:"caption",type:"checkbox",label:"Caption"}),t},xe=function(e,t){return{title:"General",type:"form",items:ye(e,t)}},we=ye,Ce=function(){return x.getOrDie("URL")},Se=function(e){return Ce().createObjectURL(e)},Ne=function(e){Ce().revokeObjectURL(e)},_e=tinymce.util.Tools.resolve("tinymce.ui.Factory"),Te=function(){};function Ae(i){var t=function(e,r,a,t){var o,n;(o=new(x.getOrDie("XMLHttpRequest"))).open("POST",i.url),o.withCredentials=i.credentials,o.upload.onprogress=function(e){t(e.loaded/e.total*100)},o.onerror=function(){a("Image upload failed due to a XHR Transport error. Code: "+o.status)},o.onload=function(){var e,t,n;o.status<200||300<=o.status?a("HTTP Error: "+o.status):(e=JSON.parse(o.responseText))&&"string"==typeof e.location?r((t=i.basePath,n=e.location,t?t.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):a("Invalid JSON: "+o.responseText)},(n=new l.FormData).append("file",e.blob(),e.filename()),o.send(n)};return i=C.extend({credentials:!1,handler:t},i),{upload:function(e){return i.url||i.handler!==t?(r=e,a=i.handler,new w(function(e,t){try{a(r,e,t,Te)}catch(n){t(n.message)}})):w.reject("Upload url missing from the settings.");var r,a}}}var Re=function(u){return function(e){var t=_e.get("Throbber"),n=e.control.rootControl,r=new t(n.getEl()),a=e.control.value(),o=Se(a),i=Ae({url:f(u),basePath:h(u),credentials:v(u),handler:p(u)}),l=function(){r.hide(),Ne(o)};return r.show(),L(a).then(function(e){var t=u.editorUpload.blobCache.create({blob:a,blobUri:o,name:a.name?a.name.replace(/\.[^\.]+$/,""):null,base64:e.split(",")[1]});return i.upload(t).then(function(e){var t=n.find("#src");return t.value(e),n.find("tabpanel")[0].activateTab(0),t.fire("change"),l(),e})})["catch"](function(e){u.windowManager.alert(e),l()})}},Ie=".jpg,.jpeg,.png,.gif",Oe=function(e){return{title:"Upload",type:"form",layout:"flex",direction:"column",align:"stretch",padding:"20 20 20 20",items:[{type:"container",layout:"flex",direction:"column",align:"center",spacing:10,items:[{text:"Browse for an image",type:"browsebutton",accept:Ie,onchange:Re(e)},{text:"OR",type:"label"}]},{text:"Drop an image here",type:"dropzone",accept:Ie,height:100,onchange:Re(e)}]}};function Le(r){for(var a=[],e=1;e<arguments.length;e++)a[e-1]=arguments[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=a.concat(e);return r.apply(null,n)}}var Pe=function(t,e){var n=e.control.getRoot();ve(n),t.undoManager.transact(function(){var e=E(ie(t),n.toJSON());ue(t,e)}),t.editorUpload.uploadImagesAuto()};function Ue(o){function e(e){var n,t,r=ie(o);if(e&&(t={type:"listbox",label:"Image list",name:"image-list",values:T(e,function(e){e.value=o.convertURL(e.value||e.url,"src")},[{text:"None",value:""}]),value:r.src&&o.convertURL(r.src,"src"),onselect:function(e){var t=n.find("#alt");(!t.value()||e.lastControl&&t.value()===e.lastControl.text())&&t.value(e.control.text()),n.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){t=this}}),u(o)||s(o)||g(o)){var a=[xe(o,t)];u(o)&&a.push(se(o)),(s(o)||g(o))&&a.push(Oe(o)),n=o.windowManager.open({title:"Insert/edit image",data:r,bodyType:"tabpanel",body:a,onSubmit:Le(Pe,o)})}else n=o.windowManager.open({title:"Insert/edit image",data:r,body:we(o,t),onSubmit:Le(Pe,o)});he(n)}return{open:function(){t(o,e)}}}var Ee=function(e){e.addCommand("mceImage",Ue(e).open)},ke=function(o){return function(e){for(var t,n,r=e.length,a=function(e){e.attr("contenteditable",o?"true":null)};r--;)t=e[r],(n=t.attr("class"))&&/\bimage\b/.test(n)&&(t.attr("contenteditable",o?"false":null),C.each(t.getAll("figcaption"),a))}},Me=function(e){e.on("preInit",function(){e.parser.addNodeFilter("figure",ke(!0)),e.serializer.addNodeFilter("figure",ke(!1))})},De=function(e){e.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:Ue(e).open,stateSelector:"img:not([data-mce-object],[data-mce-placeholder]),figure.image"}),e.addMenuItem("image",{icon:"image",text:"Image",onclick:Ue(e).open,context:"insert",prependToContext:!0})};e.add("image",function(e){Me(e),De(e),Ee(e)})}(window);
\ No newline at end of file

plugins/imagetools/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var imagetools = (function () {
+var imagetools = (function (domGlobals) {
'use strict';
var Cell = function (initial) {
@@ -25,7 +25,7 @@
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
function create(width, height) {
- return resize(document.createElement('canvas'), width, height);
+ return resize(domGlobals.document.createElement('canvas'), width, height);
}
function clone(canvas) {
var tCanvas, ctx;
@@ -84,7 +84,7 @@
doResolve(fn, bind(resolve, this), bind(reject, this));
};
var asap = Promise.immediateFn || typeof window.setImmediate === 'function' && window.setImmediate || function (fn) {
- setTimeout(fn, 1);
+ domGlobals.setTimeout(fn, 1);
};
function bind(fn, thisArg) {
return function () {
@@ -240,26 +240,20 @@
return value;
};
};
- var curry = function (f) {
- var x = [];
+ function curry(fn) {
+ var initialArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
- x[_i - 1] = arguments[_i];
+ initialArgs[_i - 1] = arguments[_i];
}
- var args = new Array(arguments.length - 1);
- for (var i = 1; i < arguments.length; i++)
- args[i - 1] = arguments[i];
return function () {
- var x = [];
+ var restArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ restArgs[_i] = arguments[_i];
}
- var newArgs = new Array(arguments.length);
- for (var j = 0; j < newArgs.length; j++)
- newArgs[j] = arguments[j];
- var all = args.concat(newArgs);
- return f.apply(null, all);
- };
+ var all = initialArgs.concat(restArgs);
+ return fn.apply(null, all);
};
+ }
var never = constant(false);
var always = constant(true);
@@ -272,13 +266,13 @@
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 noop = function () {
};
var nul = function () {
return null;
@@ -294,17 +288,17 @@
isSome: never$1,
isNone: always$1,
getOr: id,
- getOrThunk: call$$1,
+ getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: nul,
getOrUndefined: undef,
or: id,
- orThunk: call$$1,
+ orThunk: call,
map: none,
ap: none,
- each: noop$$1,
+ each: noop,
bind: none,
flatten: none,
exists: never$1,
@@ -392,7 +386,7 @@
from: from
};
- 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;
@@ -453,8 +447,8 @@
}
function blobToImage(blob) {
return new Promise(function (resolve, reject) {
- var blobUrl = URL.createObjectURL(blob);
- var image = new Image();
+ var blobUrl = domGlobals.URL.createObjectURL(blob);
+ var image = new domGlobals.Image();
var removeListeners = function () {
image.removeEventListener('load', loaded);
image.removeEventListener('error', error);
@@ -477,7 +471,7 @@
}
function anyUriToBlob(url) {
return new Promise(function (resolve, reject) {
- var xhr = new XMLHttpRequest();
+ var xhr = new domGlobals.XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = function () {
@@ -542,7 +536,7 @@
}
function canvasToBlob(canvas, type, quality) {
type = type || 'image/png';
- if (HTMLCanvasElement.prototype.toBlob) {
+ if (domGlobals.HTMLCanvasElement.prototype.toBlob) {
return new Promise(function (resolve) {
canvas.toBlob(function (blob) {
resolve(blob);
@@ -592,7 +586,7 @@
});
}
function revokeImageUrl(image) {
- URL.revokeObjectURL(image.src);
+ domGlobals.URL.revokeObjectURL(image.src);
}
var Conversions = {
blobToImage: blobToImage,
@@ -709,7 +703,7 @@
}
return value;
}
- function identity$1() {
+ function identity() {
return [
1,
0,
@@ -1105,7 +1099,7 @@
], value));
}
var ColorMatrix = {
- identity: identity$1,
+ identity: identity,
adjust: adjust,
multiply: multiply,
adjustContrast: adjustContrast,
@@ -1982,7 +1976,7 @@
var revokeObjectURL = function (u) {
url().revokeObjectURL(u);
};
- var URL$1 = {
+ var URL = {
createObjectURL: createObjectURL,
revokeObjectURL: revokeObjectURL
};
@@ -2059,7 +2053,7 @@
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);
@@ -2072,7 +2066,7 @@
}
});
};
- var LoadImage = { loadImage: loadImage$1 };
+ var LoadImage = { loadImage: loadImage };
var global$8 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
@@ -2368,19 +2362,19 @@
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,
@@ -2388,13 +2382,13 @@
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) {
@@ -2409,19 +2403,19 @@
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;
@@ -2470,37 +2464,37 @@
}
},
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);
});
}
});
@@ -2511,12 +2505,12 @@
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) {
@@ -3243,7 +3237,7 @@
return slice.call(x);
};
- function XMLHttpRequest$1 () {
+ function XMLHttpRequest () {
var f = Global$1.getOrDie('XMLHttpRequest');
return new f();
}
@@ -3261,7 +3255,7 @@
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({
@@ -3556,7 +3550,7 @@
ImageSize$1.setImageSize(img, newSize);
}
}
- URL$1.revokeObjectURL(newImage.src);
+ URL.revokeObjectURL(newImage.src);
resolve(blob);
});
});
@@ -3655,5 +3649,5 @@
return Plugin;
-}());
+}(window));
})();

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 a,u,c,l,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;t<e;t++)i.call(this,this._deferreds[t]);this._deferreds=null}function c(t,e,n,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.resolve=n,this.reject=r}function l(t,e,n){var r=!1;try{t(function(t){r||(r=!0,e(t))},function(t){r||(r=!0,n(t))})}catch(o){if(r)return;r=!0,n(o)}}return t.prototype["catch"]=function(t){return this.then(null,t)},t.prototype.then=function(n,r){var o=this;return new t(function(t,e){i.call(o,new c(n,r,t,e))})},t.all=function(){var c=Array.prototype.slice.call(1===arguments.length&&n(arguments[0])?arguments[0]:arguments);return new t(function(o,i){if(0===c.length)return o([]);var a=c.length;function u(e,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void n.call(t,function(t){u(e,t)},i)}c[e]=t,0==--a&&o(c)}catch(r){i(r)}}for(var t=0;t<c.length;t++)u(t,c[t])})},t.resolve=function(e){return e&&"object"==typeof e&&e.constructor===t?e:new t(function(t){t(e)})},t.reject=function(n){return new t(function(t,e){e(n)})},t.race=function(o){return new t(function(t,e){for(var n=0,r=o.length;n<r;n++)o[n].then(t,e)})},t}(),s=function(t){return function(){return t}},f=function(i){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];for(var a=new Array(arguments.length-1),n=1;n<arguments.length;n++)a[n-1]=arguments[n];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var o=a.concat(n);return i.apply(null,o)}},d=s(!1),m=s(!0),y=d,v=m,b=function(){return w},w=(l={fold:function(t,e){return t()},is:y,isSome:y,isNone:v,getOr:c=function(t){return t},getOrThunk:u=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:c,orThunk:u,map:b,ap:b,each:function(){},bind:b,flatten:b,exists:y,forall:v,filter:b,equals:a=function(t){return t.isNone()},equals_:a,toArray:function(){return[]},toString:s("none()")},Object.freeze&&Object.freeze(l),l),x=function(n){var t=function(){return n},e=function(){return o},r=function(t){return t(n)},o={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:v,isNone:y,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return x(t(n))},ap:function(t){return t.fold(b,function(t){return x(t(n))})},each:function(t){t(n)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(n)?o:w},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(y,function(t){return e(n,t)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},I={some:x,none:b,from:function(t){return null===t||t===undefined?w:x(t)}},T="undefined"!=typeof window?window:Function("return this;")(),R=function(t,e){return function(t,e){for(var n=e!==undefined&&null!==e?e:T,r=0;r<t.length&&n!==undefined&&null!==n;++r)n=n[t[r]];return n}(t.split("."),e)},S={getOrDie:function(t,e){var n=R(t,e);if(n===undefined||null===n)throw t+" not available on this browser";return n}};function O(){return new(S.getOrDie("FileReader"))}var F={atob:function(t){return S.getOrDie("atob")(t)},requestAnimationFrame:function(t){S.getOrDie("requestAnimationFrame")(t)}};function C(u){return new g(function(t,e){var n=URL.createObjectURL(u),r=new Image,o=function(){r.removeEventListener("load",i),r.removeEventListener("error",a)};function i(){o(),t(r)}function a(){o(),e("Unable to load data of type "+u.type+": "+n)}r.addEventListener("load",i),r.addEventListener("error",a),r.src=n,r.complete&&i()})}function E(r){return new g(function(t,n){var e=new XMLHttpRequest;e.open("GET",r,!0),e.responseType="blob",e.onload=function(){200==this.status&&t(this.response)},e.onerror=function(){var t,e=this;n(0===this.status?((t=new Error("No access to download image")).code=18,t.name="SecurityError",t):new Error("Error "+e.status+" downloading image"))},e.send()})}function D(t){var e=t.split(","),n=/data:([^;]+)/.exec(e[0]);if(!n)return I.none();for(var r,o,i,a=n[1],u=e[1],c=F.atob(u),l=c.length,s=Math.ceil(l/1024),f=new Array(s),d=0;d<s;++d){for(var h=1024*d,p=Math.min(h+1024,l),g=new Array(p-h),m=h,y=0;m<p;++y,++m)g[y]=c[m].charCodeAt(0);f[d]=(r=g,new(S.getOrDie("Uint8Array"))(r))}return I.some((o=f,i={type:a},new(S.getOrDie("Blob"))(o,i)))}function A(n){return new g(function(t,e){D(n).fold(function(){e("uri is not base64: "+n)},t)})}function _(n){return new g(function(t){var e=O();e.onloadend=function(){t(e.result)},e.readAsDataURL(n)})}var k={blobToImage:C,imageToBlob:function(t){var e=t.src;return 0===e.indexOf("data:")?A(e):E(e)},blobToArrayBuffer:function(n){return new g(function(t){var e=O();e.onloadend=function(){t(e.result)},e.readAsArrayBuffer(n)})},blobToDataUri:_,blobToBase64:function(t){return _(t).then(function(t){return t.split(",")[1]})},dataUriToBlobSync:D,canvasToBlob:function(t,n,r){return n=n||"image/png",HTMLCanvasElement.prototype.toBlob?new g(function(e){t.toBlob(function(t){e(t)},n,r)}):A(t.toDataURL(n,r))},canvasToDataURL:function(t,e,n){return e=e||"image/png",t.then(function(t){return t.toDataURL(e,n)})},blobToCanvas:function(t){return C(t).then(function(t){var e,n;return e=t,URL.revokeObjectURL(e.src),n=h.create(p.getWidth(t),p.getHeight(t)),h.get2dContext(n).drawImage(t,0,0),n})},uriToBlob:function(t){return 0===t.indexOf("blob:")?E(t):0===t.indexOf("data:")?A(t):null}},L=function(t){return k.blobToImage(t)},P=function(t){return k.imageToBlob(t)};function B(t,e,n){var r=e.type;function o(e,n){return t.then(function(t){return k.canvasToDataURL(t,e,n)})}return{getType:s(r),toBlob:function(){return g.resolve(e)},toDataURL:function(){return n},toBase64:function(){return n.split(",")[1]},toAdjustedBlob:function(e,n){return t.then(function(t){return k.canvasToBlob(t,e,n)})},toAdjustedDataURL:o,toAdjustedBase64:function(t,e){return o(t,e).then(function(t){return t.split(",")[1]})},toCanvas:function(){return t.then(h.clone)}}}function H(e){return k.blobToDataUri(e).then(function(t){return B(k.blobToCanvas(e),e,t)})}var M={fromBlob:H,fromCanvas:function(e,t){return k.canvasToBlob(e,t).then(function(t){return B(g.resolve(e),t,e.toDataURL())})},fromImage:function(t){return k.imageToBlob(t).then(function(t){return H(t)})},fromBlobAndUrlSync:function(t,e){return B(k.blobToCanvas(t),t,e)}};function N(t,e,n){return n<(t=parseFloat(t))?t=n:t<e&&(t=e),t}var U=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10];function j(t,e){var n,r,o,i,a=[],u=new Array(10);for(n=0;n<5;n++){for(r=0;r<5;r++)a[r]=e[r+5*n];for(r=0;r<5;r++){for(o=i=0;o<5;o++)i+=t[r+5*o]*a[o];u[r+5*n]=i}}return u}function G(t,n){return n=N(n,0,1),t.map(function(t,e){return e%6==0?t=1-(1-t)*n:t*=n,N(t,0,1)})}var z={identity:function(){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]},adjust:G,multiply:j,adjustContrast:function(t,e){var n;return e=N(e,-1,1),j(t,[(n=(e*=100)<0?127+e/100*127:127*(n=0==(n=e%1)?U[e]:U[Math.floor(e)]*(1-n)+U[Math.floor(e)+1]*n)+127)/127,0,0,0,.5*(127-n),0,n/127,0,0,.5*(127-n),0,0,n/127,0,.5*(127-n),0,0,0,1,0,0,0,0,0,1])},adjustBrightness:function(t,e){return j(t,[1,0,0,0,e=N(255*e,-255,255),0,1,0,0,e,0,0,1,0,e,0,0,0,1,0,0,0,0,0,1])},adjustSaturation:function(t,e){var n;return j(t,[.3086*(1-(n=1+(0<(e=N(e,-1,1))?3*e:e)))+n,.6094*(1-n),.082*(1-n),0,0,.3086*(1-n),.6094*(1-n)+n,.082*(1-n),0,0,.3086*(1-n),.6094*(1-n),.082*(1-n)+n,0,0,0,0,0,1,0,0,0,0,0,1])},adjustHue:function(t,e){var n,r,o,i,a;return e=N(e,-180,180)/180*Math.PI,j(t,[(o=.213)+.787*(n=Math.cos(e))+(r=Math.sin(e))*-o,(i=.715)+n*-i+r*-i,(a=.072)+n*-a+.928*r,0,0,o+n*-o+.143*r,i+n*(1-i)+.14*r,a+n*-a+-.283*r,0,0,o+n*-o+-.787*r,i+n*-i+r*i,a+.928*n+r*a,0,0,0,0,0,1,0,0,0,0,0,1])},adjustColors:function(t,e,n,r){return j(t,[e=N(e,0,2),0,0,0,0,0,n=N(n,0,2),0,0,0,0,0,r=N(r,0,2),0,0,0,0,0,1,0,0,0,0,0,1])},adjustSepia:function(t,e){return j(t,G([.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0,0,0,0,0,1],e=N(e,0,1)))},adjustGrayscale:function(t,e){return j(t,G([.33,.34,.33,0,0,.33,.34,.33,0,0,.33,.34,.33,0,0,0,0,0,1,0,0,0,0,0,1],e=N(e,0,1)))}};function V(a,u){return a.toCanvas().then(function(t){return e=t,n=a.getType(),r=u,i=h.get2dContext(e),o=function(t,e){var n,r,o,i,a,u=t.data,c=e[0],l=e[1],s=e[2],f=e[3],d=e[4],h=e[5],p=e[6],g=e[7],m=e[8],y=e[9],v=e[10],b=e[11],w=e[12],x=e[13],I=e[14],T=e[15],R=e[16],S=e[17],O=e[18],F=e[19];for(a=0;a<u.length;a+=4)n=u[a],r=u[a+1],o=u[a+2],i=u[a+3],u[a]=n*c+r*l+o*s+i*f+d,u[a+1]=n*h+r*p+o*g+i*m+y,u[a+2]=n*v+r*b+o*w+i*x+I,u[a+3]=n*T+r*R+o*S+i*O+F;return t}(i.getImageData(0,0,e.width,e.height),r),i.putImageData(o,0,0),M.fromCanvas(e,n);var e,n,r,o,i})}function W(u,c){return u.toCanvas().then(function(t){return e=t,n=u.getType(),r=c,a=h.get2dContext(e),o=a.getImageData(0,0,e.width,e.height),i=a.getImageData(0,0,e.width,e.height),i=function(t,e,n){var r,o,i,a,u,c,l,s,f,d,h,p,g,m,y,v,b;function w(t,e,n){return n<t?t=n:t<e&&(t=e),t}for(i=Math.round(Math.sqrt(n.length)),a=Math.floor(i/2),r=t.data,o=e.data,v=t.width,b=t.height,c=0;c<b;c++)for(u=0;u<v;u++){for(l=s=f=0,h=0;h<i;h++)for(d=0;d<i;d++)p=w(u+d-a,0,v-1),g=w(c+h-a,0,b-1),m=4*(g*v+p),y=n[h*i+d],l+=r[m]*y,s+=r[m+1]*y,f+=r[m+2]*y;o[m=4*(c*v+u)]=w(l,0,255),o[m+1]=w(s,0,255),o[m+2]=w(f,0,255)}return e}(o,i,r),a.putImageData(i,0,0),M.fromCanvas(e,n);var e,n,r,o,i,a})}function q(u){return function(e,n){return e.toCanvas().then(function(t){return function(t,e,n){var r,o,i=h.get2dContext(t),a=new Array(256);for(o=0;o<a.length;o++)a[o]=u(o,n);return r=function(t,e){var n,r=t.data;for(n=0;n<r.length;n+=4)r[n]=e[r[n]],r[n+1]=e[r[n+1]],r[n+2]=e[r[n+2]];return t}(i.getImageData(0,0,t.width,t.height),a),i.putImageData(r,0,0),M.fromCanvas(t,e)}(t,e.getType(),n)})}}function Y(n){return function(t,e){return V(t,n(z.identity(),e))}}function X(e){return function(t){return W(t,e)}}var J,K={invert:(J=[-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0],function(t){return V(t,J)}),brightness:Y(z.adjustBrightness),hue:Y(z.adjustHue),saturate:Y(z.adjustSaturation),contrast:Y(z.adjustContrast),grayscale:Y(z.adjustGrayscale),sepia:Y(z.adjustSepia),colorize:function(t,e,n,r){return V(t,z.adjustColors(z.identity(),e,n,r))},sharpen:X([0,-1,0,-1,5,-1,0,-1,0]),emboss:X([-2,-1,0,-1,1,1,0,1,2]),gamma:q(function(t,e){return 255*Math.pow(t/255,1-e)}),exposure:q(function(t,e){return 255*(1-Math.exp(-t/255*e))}),colorFilter:V,convoluteFilter:W},Z={scale:function e(t,n,r){var o=p.getWidth(t),i=p.getHeight(t),a=n/o,u=r/i,c=!1;(a<.5||2<a)&&(a=a<.5?.5:2,c=!0),(u<.5||2<u)&&(u=u<.5?.5:2,c=!0);var l,s,f,d=(l=t,s=a,f=u,new g(function(t){var e=p.getWidth(l),n=p.getHeight(l),r=Math.floor(e*s),o=Math.floor(n*f),i=h.create(r,o),a=h.get2dContext(i);a.drawImage(l,0,0,e,n,0,0,r,o),t(i)}));return c?d.then(function(t){return e(t,n,r)}):d}},Q={rotate:function(c,l){return c.toCanvas().then(function(t){return e=t,n=c.getType(),r=l,o=h.create(e.width,e.height),i=h.get2dContext(o),90!=(r=r<(u=a=0)?360+r:r)&&270!=r||h.resize(o,o.height,o.width),90!=r&&180!=r||(a=o.width),270!=r&&180!=r||(u=o.height),i.translate(a,u),i.rotate(r*Math.PI/180),i.drawImage(e,0,0),M.fromCanvas(o,n);var e,n,r,o,i,a,u})},flip:function(a,u){return a.toCanvas().then(function(t){return e=t,n=a.getType(),r=u,o=h.create(e.width,e.height),i=h.get2dContext(o),"v"==r?(i.scale(1,-1),i.drawImage(e,0,-o.height)):(i.scale(-1,1),i.drawImage(e,-o.width,0)),M.fromCanvas(o,n);var e,n,r,o,i})},crop:function(c,l,s,f,d){return c.toCanvas().then(function(t){return e=t,n=c.getType(),r=l,o=s,i=f,a=d,u=h.create(i,a),h.get2dContext(u).drawImage(e,-r,-o),M.fromCanvas(u,n);var e,n,r,o,i,a,u})},resize:function(e,n,r){return e.toCanvas().then(function(t){return Z.scale(t,n,r).then(function(t){return M.fromCanvas(t,e.getType())})})}},tt=function(){function t(t){this.littleEndian=!1,this._dv=new DataView(t)}return t.prototype.readByteAt=function(t){return this._dv.getUint8(t)},t.prototype.read=function(t,e){if(t+e>this.length())return null;for(var n=this.littleEndian?0:-8*(e-1),r=0,o=0;r<e;r++)o|=this.readByteAt(t+r)<<Math.abs(n+8*r);return o},t.prototype.BYTE=function(t){return this.read(t,1)},t.prototype.SHORT=function(t){return this.read(t,2)},t.prototype.LONG=function(t){return this.read(t,4)},t.prototype.SLONG=function(t){var e=this.read(t,4);return 2147483647<e?e-4294967296:e},t.prototype.CHAR=function(t){return String.fromCharCode(this.read(t,1))},t.prototype.STRING=function(t,e){return this.asArray("CHAR",t,e).join("")},t.prototype.SEGMENT=function(t,e){var n=this._dv.buffer;switch(arguments.length){case 2:return n.slice(t,t+e);case 1:return n.slice(t);default:return n}},t.prototype.asArray=function(t,e,n){for(var r=[],o=0;o<n;o++)r[o]=this[t](e+o);return r},t.prototype.length=function(){return this._dv?this._dv.byteLength:0},t}(),et={274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},nt={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"},rt={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},ot={513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"},it={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"}},at=function(){function t(t){this._offsets={tiffHeader:10,IFD0:null,IFD1:null,exifIFD:null,gpsIFD:null},this._tiffTags={};var e=this;if(e._reader=new tt(t),e._idx=e._offsets.tiffHeader,65505!==e.SHORT(0)||"EXIF\0"!==e.STRING(4,5).toUpperCase())throw new Error("Exif data cannot be read or not available.");if(e._reader.littleEndian=18761==e.SHORT(e._idx),42!==e.SHORT(e._idx+=2))throw new Error("Invalid Exif data.");e._offsets.IFD0=e._offsets.tiffHeader+e.LONG(e._idx+=2),e._tiffTags=e.extractTags(e._offsets.IFD0,et),"ExifIFDPointer"in e._tiffTags&&(e._offsets.exifIFD=e._offsets.tiffHeader+e._tiffTags.ExifIFDPointer,delete e._tiffTags.ExifIFDPointer),"GPSInfoIFDPointer"in e._tiffTags&&(e._offsets.gpsIFD=e._offsets.tiffHeader+e._tiffTags.GPSInfoIFDPointer,delete e._tiffTags.GPSInfoIFDPointer);var n=e.LONG(e._offsets.IFD0+12*e.SHORT(e._offsets.IFD0)+2);n&&(e._offsets.IFD1=e._offsets.tiffHeader+n)}return t.prototype.BYTE=function(t){return this._reader.BYTE(t)},t.prototype.SHORT=function(t){return this._reader.SHORT(t)},t.prototype.LONG=function(t){return this._reader.LONG(t)},t.prototype.SLONG=function(t){return this._reader.SLONG(t)},t.prototype.CHAR=function(t){return this._reader.CHAR(t)},t.prototype.STRING=function(t,e){return this._reader.STRING(t,e)},t.prototype.SEGMENT=function(t,e){return this._reader.SEGMENT(t,e)},t.prototype.asArray=function(t,e,n){for(var r=[],o=0;o<n;o++)r[o]=this[t](e+o);return r},t.prototype.length=function(){return this._reader.length()},t.prototype.UNDEFINED=function(){return this.BYTE.apply(this,arguments)},t.prototype.RATIONAL=function(t){return this.LONG(t)/this.LONG(t+4)},t.prototype.SRATIONAL=function(t){return this.SLONG(t)/this.SLONG(t+4)},t.prototype.ASCII=function(t){return this.CHAR(t)},t.prototype.TIFF=function(){return this._tiffTags},t.prototype.EXIF=function(){var t=null;if(this._offsets.exifIFD){try{t=this.extractTags(this._offsets.exifIFD,nt)}catch(r){return null}if(t.ExifVersion&&Array.isArray(t.ExifVersion)){for(var e=0,n="";e<t.ExifVersion.length;e++)n+=String.fromCharCode(t.ExifVersion[e]);t.ExifVersion=n}}return t},t.prototype.GPS=function(){var t=null;if(this._offsets.gpsIFD){try{t=this.extractTags(this._offsets.gpsIFD,rt)}catch(e){return null}t.GPSVersionID&&Array.isArray(t.GPSVersionID)&&(t.GPSVersionID=t.GPSVersionID.join("."))}return t},t.prototype.thumb=function(){var t=this;if(t._offsets.IFD1)try{var e=t.extractTags(t._offsets.IFD1,ot);if("JPEGInterchangeFormat"in e)return t.SEGMENT(t._offsets.tiffHeader+e.JPEGInterchangeFormat,e.JPEGInterchangeFormatLength)}catch(n){}return null},t.prototype.extractTags=function(t,e){var n,r,o,i,a,u,c,l,s=this,f=[],d={},h={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},p={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(n=s.SHORT(t),r=0;r<n;r++)if(f=[],c=t+2+12*r,(o=e[s.SHORT(c)])!==undefined){if(i=h[s.SHORT(c+=2)],a=s.LONG(c+=2),!(u=p[i]))throw new Error("Invalid Exif data.");if(c+=4,4<u*a&&(c=s.LONG(c)+s._offsets.tiffHeader),c+u*a>=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('<div id="'+u+'" class="'+e+'croprect-container" role="grid" aria-dropeffect="execute">').appendTo(r),$.each(i,function(t){It("#"+u,r).append('<div id="'+u+"-"+t+'"class="'+e+'croprect-block" style="display: none" data-mce-bogus="all">')}),$.each(a,function(t){It("#"+u,r).append('<div id="'+u+"-"+t.name+'" class="'+e+"croprect-handle "+e+"croprect-handle-"+t.name+'"style="display: none" data-mce-bogus="all" role="gridcell" tabindex="-1" aria-label="'+t.label+'" aria-grabbed="false">')}),t=$.map(a,function(e){var n;return new(bt.get("DragHelper"))(u,{document:r.ownerDocument,handle:u+"-"+e.name,start:function(){n=l},drag:function(t){c(e,n,t.deltaX,t.deltaY)}})}),h(l),It(r).on("focusin focusout",function(t){It(t.target).attr("aria-grabbed","focus"===t.type)}),It(r).on("keydown",function(e){var i;function t(t,e,n,r,o){t.stopPropagation(),t.preventDefault(),c(i,n,r,o)}switch($.each(a,function(t){if(e.target.id===u+"-"+t.name)return i=t,!1}),e.keyCode){case Rt.LEFT:t(e,0,l,-10,0);break;case Rt.RIGHT:t(e,0,l,10,0);break;case Rt.UP:t(e,0,l,0,-10);break;case Rt.DOWN:t(e,0,l,0,10);break;case Rt.ENTER:case Rt.SPACEBAR:e.preventDefault(),o()}}),f=$.extend({toggleVisibility:function(t){var e;e=$.map(a,function(t){return"#"+u+"-"+t.name}).concat($.map(i,function(t){return"#"+u+"-"+t})).join(","),t?It(e,r).show():It(e,r).hide()},setClampRect:function(t){s=t,h(l)},setRect:p,getInnerRect:function(){return d(s,l)},setInnerRect:g,setViewPortRect:function(t){n=t,h(l)},destroy:function(){$.each(t,function(t){t.destroy()}),t=[]}},Tt)}(t,r.state.get("viewRect"),r.state.get("viewRect"),r.getEl(),function(){r.fire("crop")}),r.cropRect.on("updateRect",function(t){var e=t.rect,n=r.zoom();e={x:Math.round(e.x/n),y:Math.round(e.y/n),w:Math.round(e.w/n),h:Math.round(e.h/n)},r.state.set("rect",e)}),r.on("remove",r.cropRect.destroy)}r.state.on("change:cropEnabled",function(t){r.cropRect.toggleVisibility(t.value),r.repaintImage()}),r.state.on("change:zoom",function(){r.repaintImage()}),r.state.on("change:rect",function(t){var e=t.value;r.cropRect||n(e),r.cropRect.setRect(e)})}}))(t)}};function Ft(t){return{blob:t,url:pt.createObjectURL(t)}}function Ct(t){t&&pt.revokeObjectURL(t.url)}function Et(t){$.each(t,Ct)}function Dt(i,a,t,e){var u,n,r,c,o,l,s,f,d,h,p,g,m,y,v,b,w,x,I,T,R,S,O,F,C,E,D,A=function(){var n=[],r=-1;function t(){return 0<r}function e(){return-1!==r&&r<n.length-1}return{data:n,add:function(t){var e;return e=n.splice(++r),n.push(t),{state:t,removed:e}},undo:function(){if(t())return n[--r]},redo:function(){if(e())return n[++r]},canUndo:t,canRedo:e}}(),_=function(t){return i.rtl?t.reverse():t};function k(t){var e,n,r,o;e=u.find("#w")[0],n=u.find("#h")[0],r=parseInt(e.value(),10),o=parseInt(n.value(),10),u.find("#constrain")[0].checked()&&F&&C&&r&&o&&("w"===t.control.settings.name?(o=Math.round(r*E),n.value(o)):(r=Math.round(o*D),e.value(r))),F=r,C=o}function L(t){return Math.round(100*t)+"%"}function P(){u.find("#undo").disabled(!A.canUndo()),u.find("#redo").disabled(!A.canRedo()),u.statusbar.find("#save").disabled(!A.canUndo())}function B(){u.find("#undo").disabled(!0),u.find("#redo").disabled(!0)}function H(t){t&&f.imageSrc(t.url)}function M(e){return function(){var t=$.grep(O,function(t){return t.settings.name!==e});$.each(t,function(t){t.hide()}),e.show(),e.focus()}}function N(t){H(c=Ft(t))}function U(t){H(a=Ft(t)),Et(A.add(a).removed),P()}function j(){var e=f.selection();dt.blobToImageResult(a.blob).then(function(t){st.crop(t,e.x,e.y,e.w,e.h).then(q).then(function(t){U(t),z()})})}var G=function(e){var n=[].slice.call(arguments,1);return function(){var t=c||a;dt.blobToImageResult(t.blob).then(function(t){e.apply(this,[t].concat(n)).then(q).then(N)})}};function z(){H(a),Ct(c),M(n)(),P()}function V(){c?(U(c.blob),z()):function t(e,n){c?n():setTimeout(function(){0<e--?t(e,n):i.windowManager.alert("Error: failed to apply image operation.")},10)}(100,V)}function W(t){return bt.create("Form",{layout:"flex",direction:"row",labelGap:5,border:"0 0 1 0",align:"center",pack:"center",padding:"0 10 0 10",spacing:5,flex:0,minHeight:60,defaults:{classes:"imagetool",type:"button"},items:t})}var q=function(t){return t.toBlob()};function Y(t,e){return W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",function(){B(),dt.blobToImageResult(a.blob).then(function(t){return e(t)}).then(q).then(function(t){var e=Ft(t);H(e),Ct(c),c=e})})}function X(t,n,e,r,o){return W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{type:"slider",flex:1,ondragend:function(t){var e;e=t.value,dt.blobToImageResult(a.blob).then(function(t){return n(t,e)}).then(q).then(function(t){var e=Ft(t);H(e),Ct(c),c=e})},minValue:i.rtl?o:r,maxValue:i.rtl?r:o,value:e,previewFilter:L},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",function(){this.find("slider").value(e),B()})}o=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:j}])).hide().on("show hide",function(t){f.toggleCropRect("show"===t.type)}).on("show",B),l=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{type:"textbox",name:"w",label:"Width",size:4,onkeyup:k},{type:"textbox",name:"h",label:"Height",size:4,onkeyup:k},{type:"checkbox",name:"constrain",text:"Constrain proportions",checked:!0,onchange:function(t){!0===t.control.value()&&(E=C/F,D=F/C)}},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:"submit"}])).hide().on("submit",function(t){var e=parseInt(u.find("#w").value(),10),n=parseInt(u.find("#h").value(),10);t.preventDefault(),function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=[].slice.call(arguments,1);return function(){dt.blobToImageResult(a.blob).then(function(t){e.apply(this,[t].concat(r)).then(q).then(U)})}}(st.resize,e,n)(),z()}).on("show",B),s=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{icon:"fliph",tooltip:"Flip horizontally",onclick:G(st.flip,"h")},{icon:"flipv",tooltip:"Flip vertically",onclick:G(st.flip,"v")},{icon:"rotateleft",tooltip:"Rotate counterclockwise",onclick:G(st.rotate,-90)},{icon:"rotateright",tooltip:"Rotate clockwise",onclick:G(st.rotate,90)},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",B),p=Y(0,st.invert),I=Y(0,st.sharpen),T=Y(0,st.emboss),g=X(0,st.brightness,0,-1,1),m=X(0,st.hue,180,0,360),y=X(0,st.saturate,0,-1,1),v=X(0,st.contrast,0,-1,1),b=X(0,st.grayscale,0,0,1),w=X(0,st.sepia,0,0,1),x=function(t,o){function e(){var e,n,r;e=u.find("#r")[0].value(),n=u.find("#g")[0].value(),r=u.find("#b")[0].value(),dt.blobToImageResult(a.blob).then(function(t){return o(t,e,n,r)}).then(q).then(function(t){var e=Ft(t);H(e),Ct(c),c=e})}var n=i.rtl?2:0,r=i.rtl?0:2;return W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{type:"slider",label:"R",name:"r",minValue:n,value:1,maxValue:r,ondragend:e,previewFilter:L},{type:"slider",label:"G",name:"g",minValue:n,value:1,maxValue:r,ondragend:e,previewFilter:L},{type:"slider",label:"B",name:"b",minValue:n,value:1,maxValue:r,ondragend:e,previewFilter:L},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",function(){u.find("#r,#g,#b").value(1),B()})}(0,st.colorize),R=X(0,st.gamma,0,-1,1),S=X(0,st.exposure,1,0,2),r=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{text:"hue",icon:"hue",onclick:M(m)},{text:"saturate",icon:"saturate",onclick:M(y)},{text:"sepia",icon:"sepia",onclick:M(w)},{text:"emboss",icon:"emboss",onclick:M(T)},{text:"exposure",icon:"exposure",onclick:M(S)},{type:"spacer",flex:1}])).hide(),n=W(_([{tooltip:"Crop",icon:"crop",onclick:M(o)},{tooltip:"Resize",icon:"resize2",onclick:M(l)},{tooltip:"Orientation",icon:"orientation",onclick:M(s)},{tooltip:"Brightness",icon:"sun",onclick:M(g)},{tooltip:"Sharpen",icon:"sharpen",onclick:M(I)},{tooltip:"Contrast",icon:"contrast",onclick:M(v)},{tooltip:"Color levels",icon:"drop",onclick:M(x)},{tooltip:"Gamma",icon:"gamma",onclick:M(R)},{tooltip:"Invert",icon:"invert",onclick:M(p)}])),f=Ot.create({flex:1,imageSrc:a.url}),d=bt.create("Container",{layout:"flex",direction:"column",pack:"start",border:"0 1 0 0",padding:5,spacing:5,items:[{type:"button",icon:"undo",tooltip:"Undo",name:"undo",onclick:function(){H(a=A.undo()),P()}},{type:"button",icon:"redo",tooltip:"Redo",name:"redo",onclick:function(){H(a=A.redo()),P()}},{type:"button",icon:"zoomin",tooltip:"Zoom in",onclick:function(){var t=f.zoom();t<2&&(t+=.1),f.zoom(t)}},{type:"button",icon:"zoomout",tooltip:"Zoom out",onclick:function(){var t=f.zoom();.1<t&&(t-=.1),f.zoom(t)}}]}),h=bt.create("Container",{type:"container",layout:"flex",direction:"row",align:"stretch",flex:1,items:_([d,f])}),O=[n,o,l,s,r,p,g,m,y,v,b,w,x,I,T,R,S],(u=i.windowManager.open({layout:"flex",direction:"column",align:"stretch",minWidth:Math.min(vt.DOM.getViewPort().w,800),minHeight:Math.min(vt.DOM.getViewPort().h,650),title:"Edit image",items:O.concat([h]),buttons:_([{text:"Save",name:"save",subtype:"primary",onclick:function(){t(a.blob),u.close()}},{text:"Cancel",onclick:"close"}])})).on("close",function(){e(),Et(A.data),c=A=null}),A.add(a),P(),f.on("load",function(){F=f.imageSize().w,C=f.imageSize().h,E=C/F,D=F/C,u.find("#w").value(F),u.find("#h").value(C)}),f.on("crop",j)}var At,_t={edit:function(r,t){return new mt(function(e,n){return t.toBlob().then(function(t){Dt(r,Ft(t),e,n)})})}},kt={getImageSize:function(t){var e,n;function r(t){return/^[0-9\.]+px$/.test(t)}return e=t.style.width,n=t.style.height,e||n?r(e)&&r(n)?{w:parseInt(e,10),h:parseInt(n,10)}:null:(e=t.width,n=t.height,e&&n?{w:parseInt(e,10),h:parseInt(n,10)}:null)},setImageSize:function(t,e){var n,r;e&&(n=t.style.width,r=t.style.height,(n||r)&&(t.style.width=e.w+"px",t.style.height=e.h+"px",t.removeAttribute("data-mce-style")),n=t.width,r=t.height,(n||r)&&(t.setAttribute("width",e.w),t.setAttribute("height",e.h)))},getNaturalImageSize:function(t){return{w:t.naturalWidth,h:t.naturalHeight}}},Lt=(At="function",function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&Array.prototype.isPrototypeOf(t)?"array":"object"===e&&String.prototype.isPrototypeOf(t)?"string":e}(t)===At}),Pt=function(t,e){for(var n=0,r=t.length;n<r;n++){var o=t[n];if(e(o,n,t))return I.some(o)}return I.none()};Array.prototype.slice;Lt(Array.from)&&Array.from;var Bt=function(t){return null!==t&&t!==undefined},Ht=function(t,e){var n;return n=e.reduce(function(t,e){return Bt(t)?t[e]:undefined},t),Bt(n)?n:null},Mt=function(e){return new mt(function(n){var t=O();t.onload=function(t){var e=t.target;n(e.result)},t.readAsText(e)})},Nt=function(e,r,o){return new mt(function(t){var n;(n=new(S.getOrDie("XMLHttpRequest"))).onreadystatechange=function(){4===n.readyState&&t({status:n.status,blob:this.response})},n.open("GET",e,!0),n.withCredentials=o,$.each(r,function(t,e){n.setRequestHeader(e,t)}),n.responseType="blob",n.send()})},Ut=function(t){var e;try{e=JSON.parse(t)}catch(n){}return e},jt=[{code:404,message:"Could not find Image Proxy"},{code:403,message:"Rejected request"},{code:0,message:"Incorrect Image Proxy URL"}],Gt=[{type:"key_missing",message:"The request did not include an api key."},{type:"key_not_found",message:"The provided api key could not be found."},{type:"domain_not_trusted",message:"The api key is not valid for the request origins."}],zt=function(e){return"ImageProxy HTTP error: "+Pt(jt,function(t){return e===t.code}).fold(s("Unknown ImageProxy error"),function(t){return t.message})},Vt=function(t){var e=zt(t);return mt.reject(e)},Wt=function(e){return Pt(Gt,function(t){return t.type===e}).fold(s("Unknown service error"),function(t){return t.message})},qt=function(t,e){return Mt(e).then(function(t){var e,n,r=(e=Ut(t),"ImageProxy Service error: "+((n=Ht(e,["error","type"]))?Wt(n):"Invalid JSON in service error message"));return mt.reject(r)})},Yt=function(t,e){return 400===(n=t)||403===n||500===n?qt(0,e):Vt(t);var n},Xt=Vt,$t=function(t,e){var n,r,o,i={"Content-Type":"application/json;charset=UTF-8","tiny-api-key":e};return Nt((n=t,r=e,o=-1===n.indexOf("?")?"?":"&",/[?&]apiKey=/.test(n)||!r?n:n+o+"apiKey="+encodeURIComponent(r)),i,!1).then(function(t){return t.status<200||300<=t.status?Yt(t.status,t.blob):mt.resolve(t.blob)})},Jt=function(t,e,n){return e?$t(t,e):Nt(t,{},n).then(function(t){return t.status<200||300<=t.status?Xt(t.status):mt.resolve(t.blob)})},Kt=0,Zt=function(t,e){t.notificationManager.open({text:e,type:"error"})},Qt=function(t){return t.selection.getNode()},te=function(t,e){var n=e.src;return 0===n.indexOf("data:")||0===n.indexOf("blob:")||new yt(n).host===t.documentBaseURI.host},ee=function(t,e){return-1!==$.inArray(t.getParam("imagetools_cors_hosts",[],"string[]"),new yt(e.src).host)},ne=function(t,e){var n,r,o,i,a=e.src;return ee(t,e)?Jt(e.src,null,(r=t,o=e,-1!==$.inArray(r.getParam("imagetools_credentials_hosts",[],"string[]"),new yt(o.src).host))):te(t,e)?P(e):(a=t.getParam("imagetools_proxy"),a+=(-1===a.indexOf("?")?"?":"&")+"url="+encodeURIComponent(e.src),n=(i=t).getParam("api_key",i.getParam("imagetools_api_key","","string"),"string"),Jt(a,n,!1))},re=function(t){var e;return(e=t.editorUpload.blobCache.getByUri(Qt(t).src))?mt.resolve(e.blob()):ne(t,Qt(t))},oe=function(t){clearTimeout(t.get())},ie=function(c,l,s,f,d){return l.toBlob().then(function(t){var e,n,r,o,i,a,u;return r=c.editorUpload.blobCache,e=(i=Qt(c)).src,c.getParam("images_reuse_filename",!1,"boolean")&&((o=r.getByUri(e))?(e=o.uri(),n=o.name()):(a=c,n=(u=e.match(/\/([^\/\?]+)?\.(?:jpeg|jpg|png|gif)(?:\?|$)/i))?a.dom.encode(u[1]):null)),o=r.create({id:"imagetools"+Kt++,blob:t,base64:l.toBase64(),uri:e,name:n}),r.add(o),c.undoManager.transact(function(){c.$(i).on("load",function t(){var e,n,r;c.$(i).off("load",t),c.nodeChanged(),s?c.editorUpload.uploadImagesAuto():(oe(f),e=c,n=f,r=gt.setEditorTimeout(e,function(){e.editorUpload.uploadImagesAuto()},e.getParam("images_upload_timeout",3e4,"number")),n.set(r))}),d&&c.$(i).attr({width:d.w,height:d.h}),c.$(i).attr({src:o.blobUri()}).removeAttr("data-mce-src")}),o})},ae=function(e,n,t,r){return function(){return e._scanForImages().then(f(re,e)).then(dt.blobToImageResult).then(t).then(function(t){return ie(e,t,!1,n,r)},function(t){Zt(e,t)})}},ue=function(n,r,o){return function(){var t=kt.getImageSize(Qt(n)),e=t?{w:t.h,h:t.w}:null;return ae(n,r,function(t){return st.rotate(t,o)},e)()}},ce=function(t,e,n){return function(){return ae(t,e,function(t){return st.flip(t,n)})()}},le=function(e,r){return function(){var o=Qt(e),i=kt.getNaturalImageSize(o),n=function(r){return new mt(function(n){L(r).then(function(t){var e=kt.getNaturalImageSize(t);i.w===e.w&&i.h===e.h||kt.getImageSize(o)&&kt.setImageSize(o,e),pt.revokeObjectURL(t.src),n(r)})})};re(e).then(dt.blobToImageResult).then(f(function(e,t){return _t.edit(e,t).then(n).then(dt.blobToImageResult).then(function(t){return ie(e,t,!0,r)},function(){})},e),function(t){Zt(e,t)})}},se=function(t,e){return t.dom.is(e,"img:not([data-mce-object],[data-mce-placeholder])")&&(te(t,e)||ee(t,e)||t.settings.imagetools_proxy)},fe=oe,de=function(n,t){$.each({mceImageRotateLeft:ue(n,t,-90),mceImageRotateRight:ue(n,t,90),mceImageFlipVertical:ce(n,t,"v"),mceImageFlipHorizontal:ce(n,t,"h"),mceEditImage:le(n,t)},function(t,e){n.addCommand(e,t)})},he=function(n,r,o){n.on("NodeChange",function(t){var e=o.get();e&&e.src!==t.element.src&&(fe(r),n.editorUpload.uploadImagesAuto(),o.set(null)),se(n,t.element)&&o.set(t.element)})},pe=function(t){t.addButton("rotateleft",{title:"Rotate counterclockwise",cmd:"mceImageRotateLeft"}),t.addButton("rotateright",{title:"Rotate clockwise",cmd:"mceImageRotateRight"}),t.addButton("flipv",{title:"Flip vertically",cmd:"mceImageFlipVertical"}),t.addButton("fliph",{title:"Flip horizontally",cmd:"mceImageFlipHorizontal"}),t.addButton("editimage",{title:"Edit image",cmd:"mceEditImage"}),t.addButton("imageoptions",{title:"Image options",icon:"options",cmd:"mceImage"})},ge=function(t){t.addContextToolbar(f(se,t),t.getParam("imagetools_toolbar","rotateleft rotateright | flipv fliph | crop editimage imageoptions"))};t.add("imagetools",function(t){var e=r(0),n=r(null);de(t,e),pe(t),ge(t),he(t,e,n)})}();
\ No newline at end of file
+!function(s){"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(s.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){s.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;t<e;t++)i.call(this,this._deferreds[t]);this._deferreds=null}function c(t,e,n,r){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.resolve=n,this.reject=r}function l(t,e,n){var r=!1;try{t(function(t){r||(r=!0,e(t))},function(t){r||(r=!0,n(t))})}catch(o){if(r)return;r=!0,n(o)}}return t.prototype["catch"]=function(t){return this.then(null,t)},t.prototype.then=function(n,r){var o=this;return new t(function(t,e){i.call(o,new c(n,r,t,e))})},t.all=function(){var c=Array.prototype.slice.call(1===arguments.length&&n(arguments[0])?arguments[0]:arguments);return new t(function(o,i){if(0===c.length)return o([]);var a=c.length;function u(e,t){try{if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void n.call(t,function(t){u(e,t)},i)}c[e]=t,0==--a&&o(c)}catch(r){i(r)}}for(var t=0;t<c.length;t++)u(t,c[t])})},t.resolve=function(e){return e&&"object"==typeof e&&e.constructor===t?e:new t(function(t){t(e)})},t.reject=function(n){return new t(function(t,e){e(n)})},t.race=function(o){return new t(function(t,e){for(var n=0,r=o.length;n<r;n++)o[n].then(t,e)})},t}(),a=function(t){return function(){return t}};function u(r){for(var o=[],t=1;t<arguments.length;t++)o[t-1]=arguments[t];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o.concat(t);return r.apply(null,n)}}var c,l,f,d,m=a(!1),y=a(!0),v=m,b=y,w=function(){return x},x=(d={fold:function(t,e){return t()},is:v,isSome:v,isNone:b,getOr:f=function(t){return t},getOrThunk:l=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:f,orThunk:l,map:w,ap:w,each:function(){},bind:w,flatten:w,exists:v,forall:b,filter:w,equals:c=function(t){return t.isNone()},equals_:c,toArray:function(){return[]},toString:a("none()")},Object.freeze&&Object.freeze(d),d),I=function(n){var t=function(){return n},e=function(){return o},r=function(t){return t(n)},o={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:b,isNone:v,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return I(t(n))},ap:function(t){return t.fold(w,function(t){return I(t(n))})},each:function(t){t(n)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(n)?o:x},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(v,function(t){return e(n,t)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},T={some:I,none:w,from:function(t){return null===t||t===undefined?x:I(t)}},R="undefined"!=typeof s.window?s.window:Function("return this;")(),S=function(t,e){return function(t,e){for(var n=e!==undefined&&null!==e?e:R,r=0;r<t.length&&n!==undefined&&null!==n;++r)n=n[t[r]];return n}(t.split("."),e)},O={getOrDie:function(t,e){var n=S(t,e);if(n===undefined||null===n)throw t+" not available on this browser";return n}};function F(){return new(O.getOrDie("FileReader"))}var C={atob:function(t){return O.getOrDie("atob")(t)},requestAnimationFrame:function(t){O.getOrDie("requestAnimationFrame")(t)}};function E(u){return new g(function(t,e){var n=s.URL.createObjectURL(u),r=new s.Image,o=function(){r.removeEventListener("load",i),r.removeEventListener("error",a)};function i(){o(),t(r)}function a(){o(),e("Unable to load data of type "+u.type+": "+n)}r.addEventListener("load",i),r.addEventListener("error",a),r.src=n,r.complete&&i()})}function D(r){return new g(function(t,n){var e=new s.XMLHttpRequest;e.open("GET",r,!0),e.responseType="blob",e.onload=function(){200==this.status&&t(this.response)},e.onerror=function(){var t,e=this;n(0===this.status?((t=new Error("No access to download image")).code=18,t.name="SecurityError",t):new Error("Error "+e.status+" downloading image"))},e.send()})}function A(t){var e=t.split(","),n=/data:([^;]+)/.exec(e[0]);if(!n)return T.none();for(var r,o,i,a=n[1],u=e[1],c=C.atob(u),l=c.length,s=Math.ceil(l/1024),f=new Array(s),d=0;d<s;++d){for(var h=1024*d,p=Math.min(h+1024,l),g=new Array(p-h),m=h,y=0;m<p;++y,++m)g[y]=c[m].charCodeAt(0);f[d]=(r=g,new(O.getOrDie("Uint8Array"))(r))}return T.some((o=f,i={type:a},new(O.getOrDie("Blob"))(o,i)))}function _(n){return new g(function(t,e){A(n).fold(function(){e("uri is not base64: "+n)},t)})}function k(n){return new g(function(t){var e=F();e.onloadend=function(){t(e.result)},e.readAsDataURL(n)})}var L={blobToImage:E,imageToBlob:function(t){var e=t.src;return 0===e.indexOf("data:")?_(e):D(e)},blobToArrayBuffer:function(n){return new g(function(t){var e=F();e.onloadend=function(){t(e.result)},e.readAsArrayBuffer(n)})},blobToDataUri:k,blobToBase64:function(t){return k(t).then(function(t){return t.split(",")[1]})},dataUriToBlobSync:A,canvasToBlob:function(t,n,r){return n=n||"image/png",s.HTMLCanvasElement.prototype.toBlob?new g(function(e){t.toBlob(function(t){e(t)},n,r)}):_(t.toDataURL(n,r))},canvasToDataURL:function(t,e,n){return e=e||"image/png",t.then(function(t){return t.toDataURL(e,n)})},blobToCanvas:function(t){return E(t).then(function(t){var e,n;return e=t,s.URL.revokeObjectURL(e.src),n=h.create(p.getWidth(t),p.getHeight(t)),h.get2dContext(n).drawImage(t,0,0),n})},uriToBlob:function(t){return 0===t.indexOf("blob:")?D(t):0===t.indexOf("data:")?_(t):null}},P=function(t){return L.blobToImage(t)},B=function(t){return L.imageToBlob(t)};function H(t,e,n){var r=e.type;function o(e,n){return t.then(function(t){return L.canvasToDataURL(t,e,n)})}return{getType:a(r),toBlob:function(){return g.resolve(e)},toDataURL:function(){return n},toBase64:function(){return n.split(",")[1]},toAdjustedBlob:function(e,n){return t.then(function(t){return L.canvasToBlob(t,e,n)})},toAdjustedDataURL:o,toAdjustedBase64:function(t,e){return o(t,e).then(function(t){return t.split(",")[1]})},toCanvas:function(){return t.then(h.clone)}}}function M(e){return L.blobToDataUri(e).then(function(t){return H(L.blobToCanvas(e),e,t)})}var N={fromBlob:M,fromCanvas:function(e,t){return L.canvasToBlob(e,t).then(function(t){return H(g.resolve(e),t,e.toDataURL())})},fromImage:function(t){return L.imageToBlob(t).then(function(t){return M(t)})},fromBlobAndUrlSync:function(t,e){return H(L.blobToCanvas(t),t,e)}};function U(t,e,n){return n<(t=parseFloat(t))?t=n:t<e&&(t=e),t}var j=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10];function G(t,e){var n,r,o,i,a=[],u=new Array(10);for(n=0;n<5;n++){for(r=0;r<5;r++)a[r]=e[r+5*n];for(r=0;r<5;r++){for(o=i=0;o<5;o++)i+=t[r+5*o]*a[o];u[r+5*n]=i}}return u}function z(t,n){return n=U(n,0,1),t.map(function(t,e){return e%6==0?t=1-(1-t)*n:t*=n,U(t,0,1)})}var V={identity:function(){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]},adjust:z,multiply:G,adjustContrast:function(t,e){var n;return e=U(e,-1,1),G(t,[(n=(e*=100)<0?127+e/100*127:127*(n=0==(n=e%1)?j[e]:j[Math.floor(e)]*(1-n)+j[Math.floor(e)+1]*n)+127)/127,0,0,0,.5*(127-n),0,n/127,0,0,.5*(127-n),0,0,n/127,0,.5*(127-n),0,0,0,1,0,0,0,0,0,1])},adjustBrightness:function(t,e){return G(t,[1,0,0,0,e=U(255*e,-255,255),0,1,0,0,e,0,0,1,0,e,0,0,0,1,0,0,0,0,0,1])},adjustSaturation:function(t,e){var n;return G(t,[.3086*(1-(n=1+(0<(e=U(e,-1,1))?3*e:e)))+n,.6094*(1-n),.082*(1-n),0,0,.3086*(1-n),.6094*(1-n)+n,.082*(1-n),0,0,.3086*(1-n),.6094*(1-n),.082*(1-n)+n,0,0,0,0,0,1,0,0,0,0,0,1])},adjustHue:function(t,e){var n,r,o,i,a;return e=U(e,-180,180)/180*Math.PI,G(t,[(o=.213)+.787*(n=Math.cos(e))+(r=Math.sin(e))*-o,(i=.715)+n*-i+r*-i,(a=.072)+n*-a+.928*r,0,0,o+n*-o+.143*r,i+n*(1-i)+.14*r,a+n*-a+-.283*r,0,0,o+n*-o+-.787*r,i+n*-i+r*i,a+.928*n+r*a,0,0,0,0,0,1,0,0,0,0,0,1])},adjustColors:function(t,e,n,r){return G(t,[e=U(e,0,2),0,0,0,0,0,n=U(n,0,2),0,0,0,0,0,r=U(r,0,2),0,0,0,0,0,1,0,0,0,0,0,1])},adjustSepia:function(t,e){return G(t,z([.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0,0,0,0,0,1],e=U(e,0,1)))},adjustGrayscale:function(t,e){return G(t,z([.33,.34,.33,0,0,.33,.34,.33,0,0,.33,.34,.33,0,0,0,0,0,1,0,0,0,0,0,1],e=U(e,0,1)))}};function W(a,u){return a.toCanvas().then(function(t){return e=t,n=a.getType(),r=u,i=h.get2dContext(e),o=function(t,e){var n,r,o,i,a,u=t.data,c=e[0],l=e[1],s=e[2],f=e[3],d=e[4],h=e[5],p=e[6],g=e[7],m=e[8],y=e[9],v=e[10],b=e[11],w=e[12],x=e[13],I=e[14],T=e[15],R=e[16],S=e[17],O=e[18],F=e[19];for(a=0;a<u.length;a+=4)n=u[a],r=u[a+1],o=u[a+2],i=u[a+3],u[a]=n*c+r*l+o*s+i*f+d,u[a+1]=n*h+r*p+o*g+i*m+y,u[a+2]=n*v+r*b+o*w+i*x+I,u[a+3]=n*T+r*R+o*S+i*O+F;return t}(i.getImageData(0,0,e.width,e.height),r),i.putImageData(o,0,0),N.fromCanvas(e,n);var e,n,r,o,i})}function q(u,c){return u.toCanvas().then(function(t){return e=t,n=u.getType(),r=c,a=h.get2dContext(e),o=a.getImageData(0,0,e.width,e.height),i=a.getImageData(0,0,e.width,e.height),i=function(t,e,n){var r,o,i,a,u,c,l,s,f,d,h,p,g,m,y,v,b;function w(t,e,n){return n<t?t=n:t<e&&(t=e),t}for(i=Math.round(Math.sqrt(n.length)),a=Math.floor(i/2),r=t.data,o=e.data,v=t.width,b=t.height,c=0;c<b;c++)for(u=0;u<v;u++){for(l=s=f=0,h=0;h<i;h++)for(d=0;d<i;d++)p=w(u+d-a,0,v-1),g=w(c+h-a,0,b-1),m=4*(g*v+p),y=n[h*i+d],l+=r[m]*y,s+=r[m+1]*y,f+=r[m+2]*y;o[m=4*(c*v+u)]=w(l,0,255),o[m+1]=w(s,0,255),o[m+2]=w(f,0,255)}return e}(o,i,r),a.putImageData(i,0,0),N.fromCanvas(e,n);var e,n,r,o,i,a})}function Y(u){return function(e,n){return e.toCanvas().then(function(t){return function(t,e,n){var r,o,i=h.get2dContext(t),a=new Array(256);for(o=0;o<a.length;o++)a[o]=u(o,n);return r=function(t,e){var n,r=t.data;for(n=0;n<r.length;n+=4)r[n]=e[r[n]],r[n+1]=e[r[n+1]],r[n+2]=e[r[n+2]];return t}(i.getImageData(0,0,t.width,t.height),a),i.putImageData(r,0,0),N.fromCanvas(t,e)}(t,e.getType(),n)})}}function X(n){return function(t,e){return W(t,n(V.identity(),e))}}function J(e){return function(t){return q(t,e)}}var K,Z={invert:(K=[-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0],function(t){return W(t,K)}),brightness:X(V.adjustBrightness),hue:X(V.adjustHue),saturate:X(V.adjustSaturation),contrast:X(V.adjustContrast),grayscale:X(V.adjustGrayscale),sepia:X(V.adjustSepia),colorize:function(t,e,n,r){return W(t,V.adjustColors(V.identity(),e,n,r))},sharpen:J([0,-1,0,-1,5,-1,0,-1,0]),emboss:J([-2,-1,0,-1,1,1,0,1,2]),gamma:Y(function(t,e){return 255*Math.pow(t/255,1-e)}),exposure:Y(function(t,e){return 255*(1-Math.exp(-t/255*e))}),colorFilter:W,convoluteFilter:q},Q={scale:function e(t,n,r){var o=p.getWidth(t),i=p.getHeight(t),a=n/o,u=r/i,c=!1;(a<.5||2<a)&&(a=a<.5?.5:2,c=!0),(u<.5||2<u)&&(u=u<.5?.5:2,c=!0);var l,s,f,d=(l=t,s=a,f=u,new g(function(t){var e=p.getWidth(l),n=p.getHeight(l),r=Math.floor(e*s),o=Math.floor(n*f),i=h.create(r,o),a=h.get2dContext(i);a.drawImage(l,0,0,e,n,0,0,r,o),t(i)}));return c?d.then(function(t){return e(t,n,r)}):d}},tt={rotate:function(c,l){return c.toCanvas().then(function(t){return e=t,n=c.getType(),r=l,o=h.create(e.width,e.height),i=h.get2dContext(o),90!=(r=r<(u=a=0)?360+r:r)&&270!=r||h.resize(o,o.height,o.width),90!=r&&180!=r||(a=o.width),270!=r&&180!=r||(u=o.height),i.translate(a,u),i.rotate(r*Math.PI/180),i.drawImage(e,0,0),N.fromCanvas(o,n);var e,n,r,o,i,a,u})},flip:function(a,u){return a.toCanvas().then(function(t){return e=t,n=a.getType(),r=u,o=h.create(e.width,e.height),i=h.get2dContext(o),"v"==r?(i.scale(1,-1),i.drawImage(e,0,-o.height)):(i.scale(-1,1),i.drawImage(e,-o.width,0)),N.fromCanvas(o,n);var e,n,r,o,i})},crop:function(c,l,s,f,d){return c.toCanvas().then(function(t){return e=t,n=c.getType(),r=l,o=s,i=f,a=d,u=h.create(i,a),h.get2dContext(u).drawImage(e,-r,-o),N.fromCanvas(u,n);var e,n,r,o,i,a,u})},resize:function(e,n,r){return e.toCanvas().then(function(t){return Q.scale(t,n,r).then(function(t){return N.fromCanvas(t,e.getType())})})}},et=function(){function t(t){this.littleEndian=!1,this._dv=new DataView(t)}return t.prototype.readByteAt=function(t){return this._dv.getUint8(t)},t.prototype.read=function(t,e){if(t+e>this.length())return null;for(var n=this.littleEndian?0:-8*(e-1),r=0,o=0;r<e;r++)o|=this.readByteAt(t+r)<<Math.abs(n+8*r);return o},t.prototype.BYTE=function(t){return this.read(t,1)},t.prototype.SHORT=function(t){return this.read(t,2)},t.prototype.LONG=function(t){return this.read(t,4)},t.prototype.SLONG=function(t){var e=this.read(t,4);return 2147483647<e?e-4294967296:e},t.prototype.CHAR=function(t){return String.fromCharCode(this.read(t,1))},t.prototype.STRING=function(t,e){return this.asArray("CHAR",t,e).join("")},t.prototype.SEGMENT=function(t,e){var n=this._dv.buffer;switch(arguments.length){case 2:return n.slice(t,t+e);case 1:return n.slice(t);default:return n}},t.prototype.asArray=function(t,e,n){for(var r=[],o=0;o<n;o++)r[o]=this[t](e+o);return r},t.prototype.length=function(){return this._dv?this._dv.byteLength:0},t}(),nt={274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},rt={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"},ot={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},it={513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength"},at={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"}},ut=function(){function t(t){this._offsets={tiffHeader:10,IFD0:null,IFD1:null,exifIFD:null,gpsIFD:null},this._tiffTags={};var e=this;if(e._reader=new et(t),e._idx=e._offsets.tiffHeader,65505!==e.SHORT(0)||"EXIF\0"!==e.STRING(4,5).toUpperCase())throw new Error("Exif data cannot be read or not available.");if(e._reader.littleEndian=18761==e.SHORT(e._idx),42!==e.SHORT(e._idx+=2))throw new Error("Invalid Exif data.");e._offsets.IFD0=e._offsets.tiffHeader+e.LONG(e._idx+=2),e._tiffTags=e.extractTags(e._offsets.IFD0,nt),"ExifIFDPointer"in e._tiffTags&&(e._offsets.exifIFD=e._offsets.tiffHeader+e._tiffTags.ExifIFDPointer,delete e._tiffTags.ExifIFDPointer),"GPSInfoIFDPointer"in e._tiffTags&&(e._offsets.gpsIFD=e._offsets.tiffHeader+e._tiffTags.GPSInfoIFDPointer,delete e._tiffTags.GPSInfoIFDPointer);var n=e.LONG(e._offsets.IFD0+12*e.SHORT(e._offsets.IFD0)+2);n&&(e._offsets.IFD1=e._offsets.tiffHeader+n)}return t.prototype.BYTE=function(t){return this._reader.BYTE(t)},t.prototype.SHORT=function(t){return this._reader.SHORT(t)},t.prototype.LONG=function(t){return this._reader.LONG(t)},t.prototype.SLONG=function(t){return this._reader.SLONG(t)},t.prototype.CHAR=function(t){return this._reader.CHAR(t)},t.prototype.STRING=function(t,e){return this._reader.STRING(t,e)},t.prototype.SEGMENT=function(t,e){return this._reader.SEGMENT(t,e)},t.prototype.asArray=function(t,e,n){for(var r=[],o=0;o<n;o++)r[o]=this[t](e+o);return r},t.prototype.length=function(){return this._reader.length()},t.prototype.UNDEFINED=function(){return this.BYTE.apply(this,arguments)},t.prototype.RATIONAL=function(t){return this.LONG(t)/this.LONG(t+4)},t.prototype.SRATIONAL=function(t){return this.SLONG(t)/this.SLONG(t+4)},t.prototype.ASCII=function(t){return this.CHAR(t)},t.prototype.TIFF=function(){return this._tiffTags},t.prototype.EXIF=function(){var t=null;if(this._offsets.exifIFD){try{t=this.extractTags(this._offsets.exifIFD,rt)}catch(r){return null}if(t.ExifVersion&&Array.isArray(t.ExifVersion)){for(var e=0,n="";e<t.ExifVersion.length;e++)n+=String.fromCharCode(t.ExifVersion[e]);t.ExifVersion=n}}return t},t.prototype.GPS=function(){var t=null;if(this._offsets.gpsIFD){try{t=this.extractTags(this._offsets.gpsIFD,ot)}catch(e){return null}t.GPSVersionID&&Array.isArray(t.GPSVersionID)&&(t.GPSVersionID=t.GPSVersionID.join("."))}return t},t.prototype.thumb=function(){var t=this;if(t._offsets.IFD1)try{var e=t.extractTags(t._offsets.IFD1,it);if("JPEGInterchangeFormat"in e)return t.SEGMENT(t._offsets.tiffHeader+e.JPEGInterchangeFormat,e.JPEGInterchangeFormatLength)}catch(n){}return null},t.prototype.extractTags=function(t,e){var n,r,o,i,a,u,c,l,s=this,f=[],d={},h={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},p={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};for(n=s.SHORT(t),r=0;r<n;r++)if(f=[],c=t+2+12*r,(o=e[s.SHORT(c)])!==undefined){if(i=h[s.SHORT(c+=2)],a=s.LONG(c+=2),!(u=p[i]))throw new Error("Invalid Exif data.");if(c+=4,4<u*a&&(c=s.LONG(c)+s._offsets.tiffHeader),c+u*a>=s.length())throw new Error("Invalid Exif data.");"ASCII"!==i?(f=s.asArray(i,c,a),l=1==a?f[0]:f,at.hasOwnProperty(o)&&"object"!=typeof l?d[o]=at[o][l]:d[o]=l):d[o]=s.STRING(c,a).replace(/\0$/,"").trim()}return d},t}(),ct=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},lt=function(u){return L.blobToArrayBuffer(u).then(function(t){try{var e=new et(t);if(65496===e.SHORT(0)){var n=ct(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 ut(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+")")}})},st=function(t,e){return tt.rotate(t,e)},ft={invert:function(t){return Z.invert(t)},sharpen:function(t){return Z.sharpen(t)},emboss:function(t){return Z.emboss(t)},brightness:function(t,e){return Z.brightness(t,e)},hue:function(t,e){return Z.hue(t,e)},saturate:function(t,e){return Z.saturate(t,e)},contrast:function(t,e){return Z.contrast(t,e)},grayscale:function(t,e){return Z.grayscale(t,e)},sepia:function(t,e){return Z.sepia(t,e)},colorize:function(t,e,n,r){return Z.colorize(t,e,n,r)},gamma:function(t,e){return Z.gamma(t,e)},exposure:function(t,e){return Z.exposure(t,e)},flip:function(t,e){return tt.flip(t,e)},crop:function(t,e,n,r,o){return tt.crop(t,e,n,r,o)},resize:function(t,e,n){return tt.resize(t,e,n)},rotate:st,exifRotate:function(e){return e.toBlob().then(lt).then(function(t){switch(t.tiff.Orientation){case 6:return st(e,90);case 3:return st(e,180);case 8:return st(e,270);default:return e}},function(){return e})}},dt=function(t){return t.toBlob()},ht={blobToImageResult:function(t){return N.fromBlob(t)},fromBlobAndUrlSync:function(t,e){return N.fromBlobAndUrlSync(t,e)},imageToImageResult:function(t){return N.fromImage(t)},imageResultToBlob:function(t,e,n){return e===undefined&&n===undefined?dt(t):t.toAdjustedBlob(e,n)},imageResultToOriginalBlob:dt,imageResultToDataURL:function(t){return t.toDataURL()}},pt=function(){return O.getOrDie("URL")},gt={createObjectURL:function(t){return pt().createObjectURL(t)},revokeObjectURL:function(t){pt().revokeObjectURL(t)}},mt=tinymce.util.Tools.resolve("tinymce.util.Delay"),yt=tinymce.util.Tools.resolve("tinymce.util.Promise"),vt=tinymce.util.Tools.resolve("tinymce.util.URI"),bt=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),wt=tinymce.util.Tools.resolve("tinymce.ui.Factory"),xt=tinymce.util.Tools.resolve("tinymce.geom.Rect"),It=function(n){return new yt(function(t){var e=function(){n.removeEventListener("load",e),t(n)};n.complete?t(n):n.addEventListener("load",e)})},Tt=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),Rt=tinymce.util.Tools.resolve("tinymce.util.Observable"),St=tinymce.util.Tools.resolve("tinymce.util.VK"),Ot=0,Ft={create:function(t){return new(wt.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 s.Image;i.src=t,It(i).then(function(){var t,e,n=o.state.get("viewRect");if((e=o.$el.find("img"))[0])e.replaceWith(i);else{var r=s.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",xt.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-"+Ot++;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=xt.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),Tt("#"+u+"-"+t,r).css({left:e.x,top:e.y,width:e.w,height:e.h})}$.each(a,function(t){Tt("#"+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"],Tt('<div id="'+u+'" class="'+e+'croprect-container" role="grid" aria-dropeffect="execute">').appendTo(r),$.each(i,function(t){Tt("#"+u,r).append('<div id="'+u+"-"+t+'"class="'+e+'croprect-block" style="display: none" data-mce-bogus="all">')}),$.each(a,function(t){Tt("#"+u,r).append('<div id="'+u+"-"+t.name+'" class="'+e+"croprect-handle "+e+"croprect-handle-"+t.name+'"style="display: none" data-mce-bogus="all" role="gridcell" tabindex="-1" aria-label="'+t.label+'" aria-grabbed="false">')}),t=$.map(a,function(e){var n;return new(wt.get("DragHelper"))(u,{document:r.ownerDocument,handle:u+"-"+e.name,start:function(){n=l},drag:function(t){c(e,n,t.deltaX,t.deltaY)}})}),h(l),Tt(r).on("focusin focusout",function(t){Tt(t.target).attr("aria-grabbed","focus"===t.type)}),Tt(r).on("keydown",function(e){var i;function t(t,e,n,r,o){t.stopPropagation(),t.preventDefault(),c(i,n,r,o)}switch($.each(a,function(t){if(e.target.id===u+"-"+t.name)return i=t,!1}),e.keyCode){case St.LEFT:t(e,0,l,-10,0);break;case St.RIGHT:t(e,0,l,10,0);break;case St.UP:t(e,0,l,0,-10);break;case St.DOWN:t(e,0,l,0,10);break;case St.ENTER:case St.SPACEBAR:e.preventDefault(),o()}}),f=$.extend({toggleVisibility:function(t){var e;e=$.map(a,function(t){return"#"+u+"-"+t.name}).concat($.map(i,function(t){return"#"+u+"-"+t})).join(","),t?Tt(e,r).show():Tt(e,r).hide()},setClampRect:function(t){s=t,h(l)},setRect:p,getInnerRect:function(){return d(s,l)},setInnerRect:g,setViewPortRect:function(t){n=t,h(l)},destroy:function(){$.each(t,function(t){t.destroy()}),t=[]}},Rt)}(t,r.state.get("viewRect"),r.state.get("viewRect"),r.getEl(),function(){r.fire("crop")}),r.cropRect.on("updateRect",function(t){var e=t.rect,n=r.zoom();e={x:Math.round(e.x/n),y:Math.round(e.y/n),w:Math.round(e.w/n),h:Math.round(e.h/n)},r.state.set("rect",e)}),r.on("remove",r.cropRect.destroy)}r.state.on("change:cropEnabled",function(t){r.cropRect.toggleVisibility(t.value),r.repaintImage()}),r.state.on("change:zoom",function(){r.repaintImage()}),r.state.on("change:rect",function(t){var e=t.value;r.cropRect||n(e),r.cropRect.setRect(e)})}}))(t)}};function Ct(t){return{blob:t,url:gt.createObjectURL(t)}}function Et(t){t&&gt.revokeObjectURL(t.url)}function Dt(t){$.each(t,Et)}function At(i,a,t,e){var u,n,r,c,o,l,s,f,d,h,p,g,m,y,v,b,w,x,I,T,R,S,O,F,C,E,D,A=function(){var n=[],r=-1;function t(){return 0<r}function e(){return-1!==r&&r<n.length-1}return{data:n,add:function(t){var e;return e=n.splice(++r),n.push(t),{state:t,removed:e}},undo:function(){if(t())return n[--r]},redo:function(){if(e())return n[++r]},canUndo:t,canRedo:e}}(),_=function(t){return i.rtl?t.reverse():t};function k(t){var e,n,r,o;e=u.find("#w")[0],n=u.find("#h")[0],r=parseInt(e.value(),10),o=parseInt(n.value(),10),u.find("#constrain")[0].checked()&&F&&C&&r&&o&&("w"===t.control.settings.name?(o=Math.round(r*E),n.value(o)):(r=Math.round(o*D),e.value(r))),F=r,C=o}function L(t){return Math.round(100*t)+"%"}function P(){u.find("#undo").disabled(!A.canUndo()),u.find("#redo").disabled(!A.canRedo()),u.statusbar.find("#save").disabled(!A.canUndo())}function B(){u.find("#undo").disabled(!0),u.find("#redo").disabled(!0)}function H(t){t&&f.imageSrc(t.url)}function M(e){return function(){var t=$.grep(O,function(t){return t.settings.name!==e});$.each(t,function(t){t.hide()}),e.show(),e.focus()}}function N(t){H(c=Ct(t))}function U(t){H(a=Ct(t)),Dt(A.add(a).removed),P()}function j(){var e=f.selection();ht.blobToImageResult(a.blob).then(function(t){ft.crop(t,e.x,e.y,e.w,e.h).then(q).then(function(t){U(t),z()})})}var G=function(e){var n=[].slice.call(arguments,1);return function(){var t=c||a;ht.blobToImageResult(t.blob).then(function(t){e.apply(this,[t].concat(n)).then(q).then(N)})}};function z(){H(a),Et(c),M(n)(),P()}function V(){c?(U(c.blob),z()):function t(e,n){c?n():setTimeout(function(){0<e--?t(e,n):i.windowManager.alert("Error: failed to apply image operation.")},10)}(100,V)}function W(t){return wt.create("Form",{layout:"flex",direction:"row",labelGap:5,border:"0 0 1 0",align:"center",pack:"center",padding:"0 10 0 10",spacing:5,flex:0,minHeight:60,defaults:{classes:"imagetool",type:"button"},items:t})}var q=function(t){return t.toBlob()};function Y(t,e){return W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",function(){B(),ht.blobToImageResult(a.blob).then(function(t){return e(t)}).then(q).then(function(t){var e=Ct(t);H(e),Et(c),c=e})})}function X(t,n,e,r,o){return W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{type:"slider",flex:1,ondragend:function(t){var e;e=t.value,ht.blobToImageResult(a.blob).then(function(t){return n(t,e)}).then(q).then(function(t){var e=Ct(t);H(e),Et(c),c=e})},minValue:i.rtl?o:r,maxValue:i.rtl?r:o,value:e,previewFilter:L},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",function(){this.find("slider").value(e),B()})}o=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:j}])).hide().on("show hide",function(t){f.toggleCropRect("show"===t.type)}).on("show",B),l=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{type:"textbox",name:"w",label:"Width",size:4,onkeyup:k},{type:"textbox",name:"h",label:"Height",size:4,onkeyup:k},{type:"checkbox",name:"constrain",text:"Constrain proportions",checked:!0,onchange:function(t){!0===t.control.value()&&(E=C/F,D=F/C)}},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:"submit"}])).hide().on("submit",function(t){var e=parseInt(u.find("#w").value(),10),n=parseInt(u.find("#h").value(),10);t.preventDefault(),function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=[].slice.call(arguments,1);return function(){ht.blobToImageResult(a.blob).then(function(t){e.apply(this,[t].concat(r)).then(q).then(U)})}}(ft.resize,e,n)(),z()}).on("show",B),s=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{icon:"fliph",tooltip:"Flip horizontally",onclick:G(ft.flip,"h")},{icon:"flipv",tooltip:"Flip vertically",onclick:G(ft.flip,"v")},{icon:"rotateleft",tooltip:"Rotate counterclockwise",onclick:G(ft.rotate,-90)},{icon:"rotateright",tooltip:"Rotate clockwise",onclick:G(ft.rotate,90)},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",B),p=Y(0,ft.invert),I=Y(0,ft.sharpen),T=Y(0,ft.emboss),g=X(0,ft.brightness,0,-1,1),m=X(0,ft.hue,180,0,360),y=X(0,ft.saturate,0,-1,1),v=X(0,ft.contrast,0,-1,1),b=X(0,ft.grayscale,0,0,1),w=X(0,ft.sepia,0,0,1),x=function(t,o){function e(){var e,n,r;e=u.find("#r")[0].value(),n=u.find("#g")[0].value(),r=u.find("#b")[0].value(),ht.blobToImageResult(a.blob).then(function(t){return o(t,e,n,r)}).then(q).then(function(t){var e=Ct(t);H(e),Et(c),c=e})}var n=i.rtl?2:0,r=i.rtl?0:2;return W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{type:"slider",label:"R",name:"r",minValue:n,value:1,maxValue:r,ondragend:e,previewFilter:L},{type:"slider",label:"G",name:"g",minValue:n,value:1,maxValue:r,ondragend:e,previewFilter:L},{type:"slider",label:"B",name:"b",minValue:n,value:1,maxValue:r,ondragend:e,previewFilter:L},{type:"spacer",flex:1},{text:"Apply",subtype:"primary",onclick:V}])).hide().on("show",function(){u.find("#r,#g,#b").value(1),B()})}(0,ft.colorize),R=X(0,ft.gamma,0,-1,1),S=X(0,ft.exposure,1,0,2),r=W(_([{text:"Back",onclick:z},{type:"spacer",flex:1},{text:"hue",icon:"hue",onclick:M(m)},{text:"saturate",icon:"saturate",onclick:M(y)},{text:"sepia",icon:"sepia",onclick:M(w)},{text:"emboss",icon:"emboss",onclick:M(T)},{text:"exposure",icon:"exposure",onclick:M(S)},{type:"spacer",flex:1}])).hide(),n=W(_([{tooltip:"Crop",icon:"crop",onclick:M(o)},{tooltip:"Resize",icon:"resize2",onclick:M(l)},{tooltip:"Orientation",icon:"orientation",onclick:M(s)},{tooltip:"Brightness",icon:"sun",onclick:M(g)},{tooltip:"Sharpen",icon:"sharpen",onclick:M(I)},{tooltip:"Contrast",icon:"contrast",onclick:M(v)},{tooltip:"Color levels",icon:"drop",onclick:M(x)},{tooltip:"Gamma",icon:"gamma",onclick:M(R)},{tooltip:"Invert",icon:"invert",onclick:M(p)}])),f=Ft.create({flex:1,imageSrc:a.url}),d=wt.create("Container",{layout:"flex",direction:"column",pack:"start",border:"0 1 0 0",padding:5,spacing:5,items:[{type:"button",icon:"undo",tooltip:"Undo",name:"undo",onclick:function(){H(a=A.undo()),P()}},{type:"button",icon:"redo",tooltip:"Redo",name:"redo",onclick:function(){H(a=A.redo()),P()}},{type:"button",icon:"zoomin",tooltip:"Zoom in",onclick:function(){var t=f.zoom();t<2&&(t+=.1),f.zoom(t)}},{type:"button",icon:"zoomout",tooltip:"Zoom out",onclick:function(){var t=f.zoom();.1<t&&(t-=.1),f.zoom(t)}}]}),h=wt.create("Container",{type:"container",layout:"flex",direction:"row",align:"stretch",flex:1,items:_([d,f])}),O=[n,o,l,s,r,p,g,m,y,v,b,w,x,I,T,R,S],(u=i.windowManager.open({layout:"flex",direction:"column",align:"stretch",minWidth:Math.min(bt.DOM.getViewPort().w,800),minHeight:Math.min(bt.DOM.getViewPort().h,650),title:"Edit image",items:O.concat([h]),buttons:_([{text:"Save",name:"save",subtype:"primary",onclick:function(){t(a.blob),u.close()}},{text:"Cancel",onclick:"close"}])})).on("close",function(){e(),Dt(A.data),c=A=null}),A.add(a),P(),f.on("load",function(){F=f.imageSize().w,C=f.imageSize().h,E=C/F,D=F/C,u.find("#w").value(F),u.find("#h").value(C)}),f.on("crop",j)}var _t,kt={edit:function(r,t){return new yt(function(e,n){return t.toBlob().then(function(t){At(r,Ct(t),e,n)})})}},Lt={getImageSize:function(t){var e,n;function r(t){return/^[0-9\.]+px$/.test(t)}return e=t.style.width,n=t.style.height,e||n?r(e)&&r(n)?{w:parseInt(e,10),h:parseInt(n,10)}:null:(e=t.width,n=t.height,e&&n?{w:parseInt(e,10),h:parseInt(n,10)}:null)},setImageSize:function(t,e){var n,r;e&&(n=t.style.width,r=t.style.height,(n||r)&&(t.style.width=e.w+"px",t.style.height=e.h+"px",t.removeAttribute("data-mce-style")),n=t.width,r=t.height,(n||r)&&(t.setAttribute("width",e.w),t.setAttribute("height",e.h)))},getNaturalImageSize:function(t){return{w:t.naturalWidth,h:t.naturalHeight}}},Pt=(_t="function",function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&Array.prototype.isPrototypeOf(t)?"array":"object"===e&&String.prototype.isPrototypeOf(t)?"string":e}(t)===_t}),Bt=function(t,e){for(var n=0,r=t.length;n<r;n++){var o=t[n];if(e(o,n,t))return T.some(o)}return T.none()};Array.prototype.slice;Pt(Array.from)&&Array.from;var Ht=function(t){return null!==t&&t!==undefined},Mt=function(t,e){var n;return n=e.reduce(function(t,e){return Ht(t)?t[e]:undefined},t),Ht(n)?n:null},Nt=function(e){return new yt(function(n){var t=F();t.onload=function(t){var e=t.target;n(e.result)},t.readAsText(e)})},Ut=function(e,r,o){return new yt(function(t){var n;(n=new(O.getOrDie("XMLHttpRequest"))).onreadystatechange=function(){4===n.readyState&&t({status:n.status,blob:this.response})},n.open("GET",e,!0),n.withCredentials=o,$.each(r,function(t,e){n.setRequestHeader(e,t)}),n.responseType="blob",n.send()})},jt=function(t){var e;try{e=JSON.parse(t)}catch(n){}return e},Gt=[{code:404,message:"Could not find Image Proxy"},{code:403,message:"Rejected request"},{code:0,message:"Incorrect Image Proxy URL"}],zt=[{type:"key_missing",message:"The request did not include an api key."},{type:"key_not_found",message:"The provided api key could not be found."},{type:"domain_not_trusted",message:"The api key is not valid for the request origins."}],Vt=function(e){return"ImageProxy HTTP error: "+Bt(Gt,function(t){return e===t.code}).fold(a("Unknown ImageProxy error"),function(t){return t.message})},Wt=function(t){var e=Vt(t);return yt.reject(e)},qt=function(e){return Bt(zt,function(t){return t.type===e}).fold(a("Unknown service error"),function(t){return t.message})},Yt=function(t,e){return Nt(e).then(function(t){var e,n,r=(e=jt(t),"ImageProxy Service error: "+((n=Mt(e,["error","type"]))?qt(n):"Invalid JSON in service error message"));return yt.reject(r)})},Xt=function(t,e){return 400===(n=t)||403===n||500===n?Yt(0,e):Wt(t);var n},$t=Wt,Jt=function(t,e){var n,r,o,i={"Content-Type":"application/json;charset=UTF-8","tiny-api-key":e};return Ut((n=t,r=e,o=-1===n.indexOf("?")?"?":"&",/[?&]apiKey=/.test(n)||!r?n:n+o+"apiKey="+encodeURIComponent(r)),i,!1).then(function(t){return t.status<200||300<=t.status?Xt(t.status,t.blob):yt.resolve(t.blob)})},Kt=function(t,e,n){return e?Jt(t,e):Ut(t,{},n).then(function(t){return t.status<200||300<=t.status?$t(t.status):yt.resolve(t.blob)})},Zt=0,Qt=function(t,e){t.notificationManager.open({text:e,type:"error"})},te=function(t){return t.selection.getNode()},ee=function(t,e){var n=e.src;return 0===n.indexOf("data:")||0===n.indexOf("blob:")||new vt(n).host===t.documentBaseURI.host},ne=function(t,e){return-1!==$.inArray(t.getParam("imagetools_cors_hosts",[],"string[]"),new vt(e.src).host)},re=function(t,e){var n,r,o,i,a=e.src;return ne(t,e)?Kt(e.src,null,(r=t,o=e,-1!==$.inArray(r.getParam("imagetools_credentials_hosts",[],"string[]"),new vt(o.src).host))):ee(t,e)?B(e):(a=t.getParam("imagetools_proxy"),a+=(-1===a.indexOf("?")?"?":"&")+"url="+encodeURIComponent(e.src),n=(i=t).getParam("api_key",i.getParam("imagetools_api_key","","string"),"string"),Kt(a,n,!1))},oe=function(t){var e;return(e=t.editorUpload.blobCache.getByUri(te(t).src))?yt.resolve(e.blob()):re(t,te(t))},ie=function(t){clearTimeout(t.get())},ae=function(c,l,s,f,d){return l.toBlob().then(function(t){var e,n,r,o,i,a,u;return r=c.editorUpload.blobCache,e=(i=te(c)).src,c.getParam("images_reuse_filename",!1,"boolean")&&((o=r.getByUri(e))?(e=o.uri(),n=o.name()):(a=c,n=(u=e.match(/\/([^\/\?]+)?\.(?:jpeg|jpg|png|gif)(?:\?|$)/i))?a.dom.encode(u[1]):null)),o=r.create({id:"imagetools"+Zt++,blob:t,base64:l.toBase64(),uri:e,name:n}),r.add(o),c.undoManager.transact(function(){c.$(i).on("load",function t(){var e,n,r;c.$(i).off("load",t),c.nodeChanged(),s?c.editorUpload.uploadImagesAuto():(ie(f),e=c,n=f,r=mt.setEditorTimeout(e,function(){e.editorUpload.uploadImagesAuto()},e.getParam("images_upload_timeout",3e4,"number")),n.set(r))}),d&&c.$(i).attr({width:d.w,height:d.h}),c.$(i).attr({src:o.blobUri()}).removeAttr("data-mce-src")}),o})},ue=function(e,n,t,r){return function(){return e._scanForImages().then(u(oe,e)).then(ht.blobToImageResult).then(t).then(function(t){return ae(e,t,!1,n,r)},function(t){Qt(e,t)})}},ce=function(n,r,o){return function(){var t=Lt.getImageSize(te(n)),e=t?{w:t.h,h:t.w}:null;return ue(n,r,function(t){return ft.rotate(t,o)},e)()}},le=function(t,e,n){return function(){return ue(t,e,function(t){return ft.flip(t,n)})()}},se=function(e,r){return function(){var o=te(e),i=Lt.getNaturalImageSize(o),n=function(r){return new yt(function(n){P(r).then(function(t){var e=Lt.getNaturalImageSize(t);i.w===e.w&&i.h===e.h||Lt.getImageSize(o)&&Lt.setImageSize(o,e),gt.revokeObjectURL(t.src),n(r)})})};oe(e).then(ht.blobToImageResult).then(u(function(e,t){return kt.edit(e,t).then(n).then(ht.blobToImageResult).then(function(t){return ae(e,t,!0,r)},function(){})},e),function(t){Qt(e,t)})}},fe=function(t,e){return t.dom.is(e,"img:not([data-mce-object],[data-mce-placeholder])")&&(ee(t,e)||ne(t,e)||t.settings.imagetools_proxy)},de=ie,he=function(n,t){$.each({mceImageRotateLeft:ce(n,t,-90),mceImageRotateRight:ce(n,t,90),mceImageFlipVertical:le(n,t,"v"),mceImageFlipHorizontal:le(n,t,"h"),mceEditImage:se(n,t)},function(t,e){n.addCommand(e,t)})},pe=function(n,r,o){n.on("NodeChange",function(t){var e=o.get();e&&e.src!==t.element.src&&(de(r),n.editorUpload.uploadImagesAuto(),o.set(null)),fe(n,t.element)&&o.set(t.element)})},ge=function(t){t.addButton("rotateleft",{title:"Rotate counterclockwise",cmd:"mceImageRotateLeft"}),t.addButton("rotateright",{title:"Rotate clockwise",cmd:"mceImageRotateRight"}),t.addButton("flipv",{title:"Flip vertically",cmd:"mceImageFlipVertical"}),t.addButton("fliph",{title:"Flip horizontally",cmd:"mceImageFlipHorizontal"}),t.addButton("editimage",{title:"Edit image",cmd:"mceEditImage"}),t.addButton("imageoptions",{title:"Image options",icon:"options",cmd:"mceImage"})},me=function(t){t.addContextToolbar(u(fe,t),t.getParam("imagetools_toolbar","rotateleft rotateright | flipv fliph | crop editimage imageoptions"))};t.add("imagetools",function(t){var e=r(0),n=r(null);he(t,e),ge(t),me(t),pe(t,e,n)})}(window);
\ No newline at end of file
@@ -1,5 +1,5 @@
(function () {
-var link = (function () {
+var link = (function (domGlobals) {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
@@ -70,21 +70,21 @@
var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
var appendClickRemove = function (link, evt) {
- document.body.appendChild(link);
+ domGlobals.document.body.appendChild(link);
link.dispatchEvent(evt);
- document.body.removeChild(link);
+ domGlobals.document.body.removeChild(link);
};
- var open$$1 = function (url) {
+ var open = function (url) {
if (!global$3.ie || global$3.ie > 10) {
- var link = document.createElement('a');
+ var link = domGlobals.document.createElement('a');
link.target = '_blank';
link.href = url;
link.rel = 'noreferrer noopener';
- var evt = document.createEvent('MouseEvents');
- evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
+ var evt = domGlobals.document.createEvent('MouseEvents');
+ evt.initMouseEvent('click', true, true, domGlobals.window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
appendClickRemove(link, evt);
} else {
- var win = window.open('', '_blank');
+ var win = domGlobals.window.open('', '_blank');
if (win) {
win.opener = null;
var doc = win.document;
@@ -94,7 +94,7 @@
}
}
};
- var OpenUrl = { open: open$$1 };
+ var OpenUrl = { open: open };
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
@@ -709,5 +709,5 @@
return Plugin;
-}());
+}(window));
})();
@@ -1 +1 @@
-!function(){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.util.VK"),e=function(t){return t.target_list},o=function(t){return t.rel_list},i=function(t){return t.link_class_list},p=function(t){return"boolean"==typeof t.link_assume_external_targets&&t.link_assume_external_targets},a=function(t){return"boolean"==typeof t.link_context_toolbar&&t.link_context_toolbar},r=function(t){return t.link_list},k=function(t){return"string"==typeof t.default_link_target},y=function(t){return t.default_link_target},b=e,_=function(t,e){t.settings.target_list=e},w=function(t){return!1!==e(t)},T=o,C=function(t){return o(t)!==undefined},M=i,O=function(t){return i(t)!==undefined},R=function(t){return!1!==t.link_title},N=function(t){return"boolean"==typeof t.allow_unsafe_link_target&&t.allow_unsafe_link_target},l=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),u=tinymce.util.Tools.resolve("tinymce.Env"),c=function(t){if(!u.ie||10<u.ie){var e=document.createElement("a");e.target="_blank",e.href=t,e.rel="noreferrer noopener";var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),r=e,a=n,document.body.appendChild(r),r.dispatchEvent(a),document.body.removeChild(r)}else{var o=window.open("","_blank");if(o){o.opener=null;var i=o.document;i.open(),i.write('<meta http-equiv="refresh" content="0; url='+l.DOM.encode(t)+'">'),i.close()}}var r,a},A=tinymce.util.Tools.resolve("tinymce.util.Tools"),s=function(t,e){var n,o,i=["noopener"],r=t?t.split(/\s+/):[],a=function(t){return t.filter(function(t){return-1===A.inArray(i,t)})};return(r=e?(n=a(n=r)).length?n.concat(i):i:a(r)).length?(o=r,A.trim(o.sort().join(" "))):null},f=function(t,e){return e=e||t.selection.getNode(),m(e)?t.dom.select("a[href]",e)[0]:t.dom.getParent(e,"a[href]")},d=function(t){return t&&"A"===t.nodeName&&t.href},m=function(t){return t&&"FIGURE"===t.nodeName&&/\bimage\b/i.test(t.className)},v=function(t,e){var n,o;(o=t.dom.select("img",e)[0])&&(n=t.dom.getParents(o,"a[href]",e)[0])&&(n.parentNode.insertBefore(o,n),t.dom.remove(n))},g=function(t,e,n){var o,i;(i=t.dom.select("img",e)[0])&&(o=t.dom.create("a",n),i.parentNode.insertBefore(o,i),o.appendChild(i))},L=function(i,r){return function(o){i.undoManager.transact(function(){var t=i.selection.getNode(),e=f(i,t),n={href:o.href,target:o.target?o.target:null,rel:o.rel?o.rel:null,"class":o["class"]?o["class"]:null,title:o.title?o.title:null};C(i.settings)||!1!==N(i.settings)||(n.rel=s(n.rel,"_blank"===n.target)),o.href===r.href&&(r.attach(),r={}),e?(i.focus(),o.hasOwnProperty("text")&&("innerText"in e?e.innerText=o.text:e.textContent=o.text),i.dom.setAttribs(e,n),i.selection.select(e),i.undoManager.add()):m(t)?g(i,t,n):o.hasOwnProperty("text")?i.insertContent(i.dom.createHTML("a",n,i.dom.encode(o.text))):i.execCommand("mceInsertLink",!1,n)})}},P=function(e){return function(){e.undoManager.transact(function(){var t=e.selection.getNode();m(t)?v(e,t):e.execCommand("unlink")})}},h=d,x=function(t){return 0<A.grep(t,d).length},E=function(t){return!(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1===t.indexOf("href=")))},S=f,I=function(t,e){var n=e?e.innerText||e.textContent:t.getContent({format:"text"});return n.replace(/\uFEFF/g,"")},K=s,U=tinymce.util.Tools.resolve("tinymce.util.Delay"),D=tinymce.util.Tools.resolve("tinymce.util.XHR"),B={},F=function(t,o,e){var i=function(t,n){return n=n||[],A.each(t,function(t){var e={text:t.text||t.title};t.menu?e.menu=i(t.menu):(e.value=t.value,o&&o(e)),n.push(e)}),n};return i(t,e||[])},q=function(e,t,n){var o=e.selection.getRng();U.setEditorTimeout(e,function(){e.windowManager.confirm(t,function(t){e.selection.setRng(o),n(t)})})},V=function(a,t){var e,l,o,u,n,i,r,c,s,f,d,m={},v=a.selection,g=a.dom,h=function(t){var e=o.find("#text");(!e.value()||t.lastControl&&e.value()===t.lastControl.text())&&e.value(t.control.text()),o.find("#href").value(t.control.value())},x=function(){l||!u||m.text||this.parent().parent().find("#text")[0].value(this.value())};u=E(v.getContent()),e=S(a),m.text=l=I(a.selection,e),m.href=e?g.getAttrib(e,"href"):"",e?m.target=g.getAttrib(e,"target"):k(a.settings)&&(m.target=y(a.settings)),(d=g.getAttrib(e,"rel"))&&(m.rel=d),(d=g.getAttrib(e,"class"))&&(m["class"]=d),(d=g.getAttrib(e,"title"))&&(m.title=d),u&&(n={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){m.text=this.value()}}),t&&(i={type:"listbox",label:"Link list",values:F(t,function(t){t.value=a.convertURL(t.value||t.url,"href")},[{text:"None",value:""}]),onselect:h,value:a.convertURL(m.href,"href"),onPostRender:function(){i=this}}),w(a.settings)&&(b(a.settings)===undefined&&_(a,[{text:"None",value:""},{text:"New window",value:"_blank"}]),c={name:"target",type:"listbox",label:"Target",values:F(b(a.settings))}),C(a.settings)&&(r={name:"rel",type:"listbox",label:"Rel",values:F(T(a.settings),function(t){!1===N(a.settings)&&(t.value=K(t.value,"_blank"===m.target))})}),O(a.settings)&&(s={name:"class",type:"listbox",label:"Class",values:F(M(a.settings),function(t){t.value&&(t.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[t.value]})})})}),R(a.settings)&&(f={name:"title",type:"textbox",label:"Title",value:m.title}),o=a.windowManager.open({title:"Insert link",data:m,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:function(t){var e=t.meta||{};i&&i.value(a.convertURL(this.value(),"href")),A.each(t.meta,function(t,e){var n=o.find("#"+e);"text"===e?0===l.length&&(n.value(t),m.text=t):n.value(t)}),e.attach&&(B={href:this.value(),attach:e.attach}),e.text||x.call(this)},onkeyup:x,onpaste:x,onbeforecall:function(t){t.meta=o.toJSON()}},n,f,function(n){var o=[];if(A.each(a.dom.select("a:not([href])"),function(t){var e=t.name||t.id;e&&o.push({text:e,value:"#"+e,selected:-1!==n.indexOf("#"+e)})}),o.length)return o.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:o,onselect:h}}(m.href),i,r,c,s],onSubmit:function(t){var e=p(a.settings),n=L(a,B),o=P(a),i=A.extend({},m,t.data),r=i.href;r?(u&&i.text!==l||delete i.text,0<r.indexOf("@")&&-1===r.indexOf("//")&&-1===r.indexOf("mailto:")?q(a,"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(t){t&&(i.href="mailto:"+r),n(i)}):!0===e&&!/^\w+:/i.test(r)||!1===e&&/^\s*www[\.|\d\.]/i.test(r)?q(a,"The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){t&&(i.href="http://"+r),n(i)}):n(i)):o()}})},z=function(t){var e,n,o;n=V,"string"==typeof(o=r((e=t).settings))?D.send({url:o,success:function(t){n(e,JSON.parse(t))}}):"function"==typeof o?o(function(t){n(e,t)}):n(e,o)},H=function(t,e){return t.dom.getParent(e,"a[href]")},J=function(t){return H(t,t.selection.getStart())},$=function(t,e){if(e){var n=(i=e).getAttribute("data-mce-href")||i.getAttribute("href");if(/^#/.test(n)){var o=t.$(n);o.length&&t.selection.scrollIntoView(o[0],!0)}else c(e.href)}var i},j=function(t){return function(){z(t)}},G=function(t){return function(){$(t,J(t))}},X=function(r){return function(t){var e,n,o,i;return!!(a(r.settings)&&(!(i=r.plugins.contextmenu)||!i.isContextMenuVisible())&&h(t)&&3===(o=(n=(e=r.selection).getRng()).startContainer).nodeType&&e.isCollapsed()&&0<n.startOffset&&n.startOffset<o.data.length)}},Q=function(o){o.on("click",function(t){var e=H(o,t.target);e&&n.metaKeyPressed(t)&&(t.preventDefault(),$(o,e))}),o.on("keydown",function(t){var e,n=J(o);n&&13===t.keyCode&&!0===(e=t).altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey&&(t.preventDefault(),$(o,n))})},W=function(n){return function(){var e=this;n.on("nodechange",function(t){e.active(!n.readonly&&!!S(n,t.element))})}},Y=function(n){return function(){var e=this,t=function(t){x(t.parents)?e.show():e.hide()};x(n.dom.getParents(n.selection.getStart()))||e.hide(),n.on("nodechange",t),e.on("remove",function(){n.off("nodechange",t)})}},Z=function(t){t.addCommand("mceLink",j(t))},tt=function(t){t.addShortcut("Meta+K","",j(t))},et=function(t){t.addButton("link",{active:!1,icon:"link",tooltip:"Insert/edit link",onclick:j(t),onpostrender:W(t)}),t.addButton("unlink",{active:!1,icon:"unlink",tooltip:"Remove link",onclick:P(t),onpostrender:W(t)}),t.addContextToolbar&&t.addButton("openlink",{icon:"newtab",tooltip:"Open link",onclick:G(t)})},nt=function(t){t.addMenuItem("openlink",{text:"Open link",icon:"newtab",onclick:G(t),onPostRender:Y(t),prependToContext:!0}),t.addMenuItem("link",{icon:"link",text:"Link",shortcut:"Meta+K",onclick:j(t),stateSelector:"a[href]",context:"insert",prependToContext:!0}),t.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onclick:P(t),stateSelector:"a[href]"})},ot=function(t){t.addContextToolbar&&t.addContextToolbar(X(t),"openlink | link unlink")};t.add("link",function(t){et(t),nt(t),ot(t),Q(t),Z(t),tt(t)})}();
\ No newline at end of file
+!function(l){"use strict";var t=tinymce.util.Tools.resolve("tinymce.PluginManager"),n=tinymce.util.Tools.resolve("tinymce.util.VK"),e=function(t){return t.target_list},o=function(t){return t.rel_list},i=function(t){return t.link_class_list},p=function(t){return"boolean"==typeof t.link_assume_external_targets&&t.link_assume_external_targets},a=function(t){return"boolean"==typeof t.link_context_toolbar&&t.link_context_toolbar},r=function(t){return t.link_list},k=function(t){return"string"==typeof t.default_link_target},y=function(t){return t.default_link_target},b=e,_=function(t,e){t.settings.target_list=e},w=function(t){return!1!==e(t)},T=o,C=function(t){return o(t)!==undefined},M=i,O=function(t){return i(t)!==undefined},R=function(t){return!1!==t.link_title},N=function(t){return"boolean"==typeof t.allow_unsafe_link_target&&t.allow_unsafe_link_target},u=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),c=tinymce.util.Tools.resolve("tinymce.Env"),s=function(t){if(!c.ie||10<c.ie){var e=l.document.createElement("a");e.target="_blank",e.href=t,e.rel="noreferrer noopener";var n=l.document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,l.window,0,0,0,0,0,!1,!1,!1,!1,0,null),r=e,a=n,l.document.body.appendChild(r),r.dispatchEvent(a),l.document.body.removeChild(r)}else{var o=l.window.open("","_blank");if(o){o.opener=null;var i=o.document;i.open(),i.write('<meta http-equiv="refresh" content="0; url='+u.DOM.encode(t)+'">'),i.close()}}var r,a},A=tinymce.util.Tools.resolve("tinymce.util.Tools"),f=function(t,e){var n,o,i=["noopener"],r=t?t.split(/\s+/):[],a=function(t){return t.filter(function(t){return-1===A.inArray(i,t)})};return(r=e?(n=a(n=r)).length?n.concat(i):i:a(r)).length?(o=r,A.trim(o.sort().join(" "))):null},d=function(t,e){return e=e||t.selection.getNode(),v(e)?t.dom.select("a[href]",e)[0]:t.dom.getParent(e,"a[href]")},m=function(t){return t&&"A"===t.nodeName&&t.href},v=function(t){return t&&"FIGURE"===t.nodeName&&/\bimage\b/i.test(t.className)},g=function(t,e){var n,o;(o=t.dom.select("img",e)[0])&&(n=t.dom.getParents(o,"a[href]",e)[0])&&(n.parentNode.insertBefore(o,n),t.dom.remove(n))},h=function(t,e,n){var o,i;(i=t.dom.select("img",e)[0])&&(o=t.dom.create("a",n),i.parentNode.insertBefore(o,i),o.appendChild(i))},L=function(i,r){return function(o){i.undoManager.transact(function(){var t=i.selection.getNode(),e=d(i,t),n={href:o.href,target:o.target?o.target:null,rel:o.rel?o.rel:null,"class":o["class"]?o["class"]:null,title:o.title?o.title:null};C(i.settings)||!1!==N(i.settings)||(n.rel=f(n.rel,"_blank"===n.target)),o.href===r.href&&(r.attach(),r={}),e?(i.focus(),o.hasOwnProperty("text")&&("innerText"in e?e.innerText=o.text:e.textContent=o.text),i.dom.setAttribs(e,n),i.selection.select(e),i.undoManager.add()):v(t)?h(i,t,n):o.hasOwnProperty("text")?i.insertContent(i.dom.createHTML("a",n,i.dom.encode(o.text))):i.execCommand("mceInsertLink",!1,n)})}},P=function(e){return function(){e.undoManager.transact(function(){var t=e.selection.getNode();v(t)?g(e,t):e.execCommand("unlink")})}},x=m,E=function(t){return 0<A.grep(t,m).length},S=function(t){return!(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1===t.indexOf("href=")))},I=d,K=function(t,e){var n=e?e.innerText||e.textContent:t.getContent({format:"text"});return n.replace(/\uFEFF/g,"")},U=f,D=tinymce.util.Tools.resolve("tinymce.util.Delay"),B=tinymce.util.Tools.resolve("tinymce.util.XHR"),F={},q=function(t,o,e){var i=function(t,n){return n=n||[],A.each(t,function(t){var e={text:t.text||t.title};t.menu?e.menu=i(t.menu):(e.value=t.value,o&&o(e)),n.push(e)}),n};return i(t,e||[])},V=function(e,t,n){var o=e.selection.getRng();D.setEditorTimeout(e,function(){e.windowManager.confirm(t,function(t){e.selection.setRng(o),n(t)})})},z=function(a,t){var e,l,o,u,n,i,r,c,s,f,d,m={},v=a.selection,g=a.dom,h=function(t){var e=o.find("#text");(!e.value()||t.lastControl&&e.value()===t.lastControl.text())&&e.value(t.control.text()),o.find("#href").value(t.control.value())},x=function(){l||!u||m.text||this.parent().parent().find("#text")[0].value(this.value())};u=S(v.getContent()),e=I(a),m.text=l=K(a.selection,e),m.href=e?g.getAttrib(e,"href"):"",e?m.target=g.getAttrib(e,"target"):k(a.settings)&&(m.target=y(a.settings)),(d=g.getAttrib(e,"rel"))&&(m.rel=d),(d=g.getAttrib(e,"class"))&&(m["class"]=d),(d=g.getAttrib(e,"title"))&&(m.title=d),u&&(n={name:"text",type:"textbox",size:40,label:"Text to display",onchange:function(){m.text=this.value()}}),t&&(i={type:"listbox",label:"Link list",values:q(t,function(t){t.value=a.convertURL(t.value||t.url,"href")},[{text:"None",value:""}]),onselect:h,value:a.convertURL(m.href,"href"),onPostRender:function(){i=this}}),w(a.settings)&&(b(a.settings)===undefined&&_(a,[{text:"None",value:""},{text:"New window",value:"_blank"}]),c={name:"target",type:"listbox",label:"Target",values:q(b(a.settings))}),C(a.settings)&&(r={name:"rel",type:"listbox",label:"Rel",values:q(T(a.settings),function(t){!1===N(a.settings)&&(t.value=U(t.value,"_blank"===m.target))})}),O(a.settings)&&(s={name:"class",type:"listbox",label:"Class",values:q(M(a.settings),function(t){t.value&&(t.textStyle=function(){return a.formatter.getCssText({inline:"a",classes:[t.value]})})})}),R(a.settings)&&(f={name:"title",type:"textbox",label:"Title",value:m.title}),o=a.windowManager.open({title:"Insert link",data:m,body:[{name:"href",type:"filepicker",filetype:"file",size:40,autofocus:!0,label:"Url",onchange:function(t){var e=t.meta||{};i&&i.value(a.convertURL(this.value(),"href")),A.each(t.meta,function(t,e){var n=o.find("#"+e);"text"===e?0===l.length&&(n.value(t),m.text=t):n.value(t)}),e.attach&&(F={href:this.value(),attach:e.attach}),e.text||x.call(this)},onkeyup:x,onpaste:x,onbeforecall:function(t){t.meta=o.toJSON()}},n,f,function(n){var o=[];if(A.each(a.dom.select("a:not([href])"),function(t){var e=t.name||t.id;e&&o.push({text:e,value:"#"+e,selected:-1!==n.indexOf("#"+e)})}),o.length)return o.unshift({text:"None",value:""}),{name:"anchor",type:"listbox",label:"Anchors",values:o,onselect:h}}(m.href),i,r,c,s],onSubmit:function(t){var e=p(a.settings),n=L(a,F),o=P(a),i=A.extend({},m,t.data),r=i.href;r?(u&&i.text!==l||delete i.text,0<r.indexOf("@")&&-1===r.indexOf("//")&&-1===r.indexOf("mailto:")?V(a,"The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?",function(t){t&&(i.href="mailto:"+r),n(i)}):!0===e&&!/^\w+:/i.test(r)||!1===e&&/^\s*www[\.|\d\.]/i.test(r)?V(a,"The URL you entered seems to be an external link. Do you want to add the required http:// prefix?",function(t){t&&(i.href="http://"+r),n(i)}):n(i)):o()}})},H=function(t){var e,n,o;n=z,"string"==typeof(o=r((e=t).settings))?B.send({url:o,success:function(t){n(e,JSON.parse(t))}}):"function"==typeof o?o(function(t){n(e,t)}):n(e,o)},J=function(t,e){return t.dom.getParent(e,"a[href]")},$=function(t){return J(t,t.selection.getStart())},j=function(t,e){if(e){var n=(i=e).getAttribute("data-mce-href")||i.getAttribute("href");if(/^#/.test(n)){var o=t.$(n);o.length&&t.selection.scrollIntoView(o[0],!0)}else s(e.href)}var i},G=function(t){return function(){H(t)}},X=function(t){return function(){j(t,$(t))}},Q=function(r){return function(t){var e,n,o,i;return!!(a(r.settings)&&(!(i=r.plugins.contextmenu)||!i.isContextMenuVisible())&&x(t)&&3===(o=(n=(e=r.selection).getRng()).startContainer).nodeType&&e.isCollapsed()&&0<n.startOffset&&n.startOffset<o.data.length)}},W=function(o){o.on("click",function(t){var e=J(o,t.target);e&&n.metaKeyPressed(t)&&(t.preventDefault(),j(o,e))}),o.on("keydown",function(t){var e,n=$(o);n&&13===t.keyCode&&!0===(e=t).altKey&&!1===e.shiftKey&&!1===e.ctrlKey&&!1===e.metaKey&&(t.preventDefault(),j(o,n))})},Y=function(n){return function(){var e=this;n.on("nodechange",function(t){e.active(!n.readonly&&!!I(n,t.element))})}},Z=function(n){return function(){var e=this,t=function(t){E(t.parents)?e.show():e.hide()};E(n.dom.getParents(n.selection.getStart()))||e.hide(),n.on("nodechange",t),e.on("remove",function(){n.off("nodechange",t)})}},tt=function(t){t.addCommand("mceLink",G(t))},et=function(t){t.addShortcut("Meta+K","",G(t))},nt=function(t){t.addButton("link",{active:!1,icon:"link",tooltip:"Insert/edit link",onclick:G(t),onpostrender:Y(t)}),t.addButton("unlink",{active:!1,icon:"unlink",tooltip:"Remove link",onclick:P(t),onpostrender:Y(t)}),t.addContextToolbar&&t.addButton("openlink",{icon:"newtab",tooltip:"Open link",onclick:X(t)})},ot=function(t){t.addMenuItem("openlink",{text:"Open link",icon:"newtab",onclick:X(t),onPostRender:Z(t),prependToContext:!0}),t.addMenuItem("link",{icon:"link",text:"Link",shortcut:"Meta+K",onclick:G(t),stateSelector:"a[href]",context:"insert",prependToContext:!0}),t.addMenuItem("unlink",{icon:"unlink",text:"Remove link",onclick:P(t),stateSelector:"a[href]"})},it=function(t){t.addContextToolbar&&t.addContextToolbar(Q(t),"openlink | link unlink")};t.add("link",function(t){nt(t),ot(t),it(t),W(t),tt(t),et(t)})}(window);
\ No newline at end of file

plugins/lists/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var lists = (function () {
+var lists = (function (domGlobals) {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
@@ -22,9 +22,15 @@
var isListNode = function (node) {
return node && /^(OL|UL|DL)$/.test(node.nodeName);
};
+ var isOlUlNode = function (node) {
+ return node && /^(OL|UL)$/.test(node.nodeName);
+ };
var isListItemNode = function (node) {
return node && /^(LI|DT|DD)$/.test(node.nodeName);
};
+ var isDlItemNode = function (node) {
+ return node && /^(DT|DD)$/.test(node.nodeName);
+ };
var isTableCellNode = function (node) {
return node && /^(TH|TD)$/.test(node.nodeName);
};
@@ -65,6 +71,8 @@
var NodeType = {
isTextNode: isTextNode,
isListNode: isListNode,
+ isOlUlNode: isOlUlNode,
+ isDlItemNode: isDlItemNode,
isListItemNode: isListItemNode,
isTableCellNode: isTableCellNode,
isBr: isBr,
@@ -77,13 +85,28 @@
isChildOfBody: isChildOfBody
};
- var getNormalizedEndPoint = function (container, offset) {
+ var getNormalizedPoint = function (container, offset) {
+ if (NodeType.isTextNode(container)) {
+ return {
+ container: container,
+ offset: offset
+ };
+ }
var node = global$1.getNode(container, offset);
- if (NodeType.isListItemNode(container) && NodeType.isTextNode(node)) {
- var textNodeOffset = offset >= container.childNodes.length ? node.data.length : 0;
+ if (NodeType.isTextNode(node)) {
return {
container: node,
- offset: textNodeOffset
+ offset: offset >= container.childNodes.length ? node.data.length : 0
+ };
+ } else if (node.previousSibling && NodeType.isTextNode(node.previousSibling)) {
+ return {
+ container: node.previousSibling,
+ offset: node.previousSibling.data.length
+ };
+ } else if (node.nextSibling && NodeType.isTextNode(node.nextSibling)) {
+ return {
+ container: node.nextSibling,
+ offset: 0
};
}
return {
@@ -93,14 +116,14 @@
};
var normalizeRange = function (rng) {
var outRng = rng.cloneRange();
- var rangeStart = getNormalizedEndPoint(rng.startContainer, rng.startOffset);
+ var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
outRng.setStart(rangeStart.container, rangeStart.offset);
- var rangeEnd = getNormalizedEndPoint(rng.endContainer, rng.endOffset);
+ var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
outRng.setEnd(rangeEnd.container, rangeEnd.offset);
return outRng;
};
var Range = {
- getNormalizedEndPoint: getNormalizedEndPoint,
+ getNormalizedPoint: getNormalizedPoint,
normalizeRange: normalizeRange
};
@@ -181,37 +204,297 @@
resolveBookmark: resolveBookmark
};
- var DOM$1 = global$6.DOM;
- var normalizeList = function (dom, ul) {
- var sibling;
- var parentNode = ul.parentNode;
- if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) {
- sibling = parentNode.previousSibling;
- if (sibling && sibling.nodeName === 'LI') {
- sibling.appendChild(ul);
- if (NodeType.isEmpty(dom, parentNode)) {
- DOM$1.remove(parentNode);
- }
- } else {
- DOM$1.setStyle(parentNode, 'listStyleType', 'none');
- }
- }
- if (NodeType.isListNode(parentNode)) {
- sibling = parentNode.previousSibling;
- if (sibling && sibling.nodeName === 'LI') {
- sibling.appendChild(ul);
- }
- }
+ var constant = function (value) {
+ return function () {
+ return value;
};
- var normalizeLists = function (dom, element) {
- global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) {
- normalizeList(dom, ul);
- });
};
- var NormalizeLists = {
- normalizeList: normalizeList,
- normalizeLists: normalizeLists
+ var not = function (f) {
+ return function () {
+ var args = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ args[_i] = arguments[_i];
+ }
+ return !f.apply(null, args);
+ };
+ };
+ var never = constant(false);
+ var always = constant(true);
+
+ var never$1 = never;
+ var always$1 = always;
+ var none = function () {
+ return NONE;
+ };
+ var NONE = function () {
+ var eq = function (o) {
+ return o.isNone();
+ };
+ var call = function (thunk) {
+ return thunk();
+ };
+ var id = function (n) {
+ return n;
+ };
+ var noop = 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,
+ getOr: id,
+ getOrThunk: call,
+ getOrDie: function (msg) {
+ throw new Error(msg || 'error: getOrDie called on none.');
+ },
+ getOrNull: nul,
+ getOrUndefined: undef,
+ or: id,
+ orThunk: call,
+ map: none,
+ ap: none,
+ each: noop,
+ bind: none,
+ flatten: none,
+ exists: never$1,
+ forall: always$1,
+ filter: none,
+ equals: eq,
+ equals_: eq,
+ toArray: function () {
+ return [];
+ },
+ toString: constant('none()')
+ };
+ if (Object.freeze)
+ Object.freeze(me);
+ return me;
+ }();
+ var some = function (a) {
+ var constant_a = function () {
+ return a;
+ };
+ var self = function () {
+ return me;
+ };
+ var map = function (f) {
+ return some(f(a));
+ };
+ var bind = function (f) {
+ return f(a);
+ };
+ var me = {
+ fold: function (n, s) {
+ return s(a);
+ },
+ is: function (v) {
+ return a === v;
+ },
+ isSome: always$1,
+ isNone: never$1,
+ getOr: constant_a,
+ getOrThunk: constant_a,
+ getOrDie: constant_a,
+ getOrNull: constant_a,
+ getOrUndefined: constant_a,
+ or: self,
+ orThunk: self,
+ map: map,
+ ap: function (optfab) {
+ return optfab.fold(none, function (fab) {
+ return some(fab(a));
+ });
+ },
+ each: function (f) {
+ f(a);
+ },
+ bind: bind,
+ flatten: constant_a,
+ exists: bind,
+ forall: bind,
+ filter: function (f) {
+ return f(a) ? me : NONE;
+ },
+ equals: function (o) {
+ return o.is(a);
+ },
+ equals_: function (o, elementEq) {
+ return o.fold(never$1, function (b) {
+ return elementEq(a, b);
+ });
+ },
+ toArray: function () {
+ return [a];
+ },
+ toString: function () {
+ return 'some(' + a + ')';
+ }
+ };
+ return me;
+ };
+ var from = function (value) {
+ return value === null || value === undefined ? NONE : some(value);
+ };
+ var Option = {
+ some: some,
+ none: none,
+ from: from
+ };
+
+ var typeOf = function (x) {
+ if (x === null)
+ return 'null';
+ var t = typeof x;
+ if (t === 'object' && Array.prototype.isPrototypeOf(x))
+ return 'array';
+ if (t === 'object' && String.prototype.isPrototypeOf(x))
+ return 'string';
+ return t;
+ };
+ var isType = function (type) {
+ return function (value) {
+ return typeOf(value) === type;
+ };
+ };
+ var isString = isType('string');
+ var isBoolean = isType('boolean');
+ var isFunction = isType('function');
+ var isNumber = isType('number');
+
+ var map = function (xs, f) {
+ var len = xs.length;
+ var r = new Array(len);
+ for (var i = 0; i < len; i++) {
+ var x = xs[i];
+ r[i] = f(x, i, xs);
+ }
+ return r;
+ };
+ var each = function (xs, f) {
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ f(x, i, xs);
+ }
+ };
+ var filter = function (xs, pred) {
+ var r = [];
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ if (pred(x, i, xs)) {
+ r.push(x);
+ }
+ }
+ return r;
+ };
+ var groupBy = function (xs, f) {
+ if (xs.length === 0) {
+ return [];
+ } else {
+ var wasType = f(xs[0]);
+ var r = [];
+ var group = [];
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ var type = f(x);
+ if (type !== wasType) {
+ r.push(group);
+ group = [];
+ }
+ wasType = type;
+ group.push(x);
+ }
+ if (group.length !== 0) {
+ r.push(group);
+ }
+ return r;
+ }
+ };
+ var foldl = function (xs, f, acc) {
+ each(xs, function (x) {
+ acc = f(acc, x);
+ });
+ return acc;
+ };
+ var find = function (xs, pred) {
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ if (pred(x, i, xs)) {
+ return Option.some(x);
+ }
+ }
+ return Option.none();
+ };
+ var push = Array.prototype.push;
+ var flatten = function (xs) {
+ var r = [];
+ for (var i = 0, len = xs.length; i < len; ++i) {
+ if (!Array.prototype.isPrototypeOf(xs[i]))
+ throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
+ push.apply(r, xs[i]);
+ }
+ return r;
+ };
+ var bind = function (xs, f) {
+ var output = map(xs, f);
+ return flatten(output);
+ };
+ var slice = Array.prototype.slice;
+ var reverse = function (xs) {
+ var r = slice.call(xs, 0);
+ r.reverse();
+ return r;
+ };
+ var head = function (xs) {
+ return xs.length === 0 ? Option.none() : Option.some(xs[0]);
+ };
+ var last = function (xs) {
+ return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]);
+ };
+ var from$1 = isFunction(Array.from) ? Array.from : function (x) {
+ return slice.call(x);
+ };
+
+ var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
+
+ var path = function (parts, scope) {
+ var o = scope !== undefined && scope !== null ? scope : Global;
+ for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i)
+ o = o[parts[i]];
+ return o;
+ };
+ var resolve = function (p, scope) {
+ var parts = p.split('.');
+ return path(parts, scope);
+ };
+
+ var unsafe = function (name, scope) {
+ return resolve(name, scope);
+ };
+ var getOrDie = function (name, scope) {
+ var actual = unsafe(name, scope);
+ if (actual === undefined || actual === null)
+ throw name + ' not available on this browser';
+ return actual;
+ };
+ var Global$1 = { getOrDie: getOrDie };
+
+ var htmlElement = function (scope) {
+ return Global$1.getOrDie('HTMLElement', scope);
+ };
+ var isPrototypeOf = function (x) {
+ var scope = resolve('ownerDocument.defaultView', x);
+ return htmlElement(scope).prototype.isPrototypeOf(x);
};
+ var HTMLElement = { isPrototypeOf: isPrototypeOf };
var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
@@ -251,33 +534,886 @@
return NodeType.isListItemNode(block);
});
};
+ var getSelectedDlItems = function (editor) {
+ return filter(getSelectedListItems(editor), NodeType.isDlItemNode);
+ };
var getClosestListRootElm = function (editor, elm) {
var parentTableCell = editor.dom.getParents(elm, 'TD,TH');
var root = parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
return root;
};
+ var findLastParentListNode = function (editor, elm) {
+ var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm));
+ return last(parentLists);
+ };
+ var getSelectedLists = function (editor) {
+ var firstList = findLastParentListNode(editor, editor.selection.getStart());
+ var subsequentLists = filter(editor.selection.getSelectedBlocks(), NodeType.isOlUlNode);
+ return firstList.toArray().concat(subsequentLists);
+ };
+ var getSelectedListRoots = function (editor) {
+ var selectedLists = getSelectedLists(editor);
+ return getUniqueListRoots(editor, selectedLists);
+ };
+ var getUniqueListRoots = function (editor, lists) {
+ var listRoots = map(lists, function (list) {
+ return findLastParentListNode(editor, list).getOr(list);
+ });
+ return global$7.unique(listRoots);
+ };
+ var isList = function (editor) {
+ var list = getParentList(editor);
+ return HTMLElement.isPrototypeOf(list);
+ };
var Selection = {
+ isList: isList,
getParentList: getParentList,
getSelectedSubLists: getSelectedSubLists,
getSelectedListItems: getSelectedListItems,
- getClosestListRootElm: getClosestListRootElm
+ getClosestListRootElm: getClosestListRootElm,
+ getSelectedDlItems: getSelectedDlItems,
+ getSelectedListRoots: getSelectedListRoots
+ };
+
+ var fromHtml = function (html, scope) {
+ var doc = scope || domGlobals.document;
+ var div = doc.createElement('div');
+ div.innerHTML = html;
+ if (!div.hasChildNodes() || div.childNodes.length > 1) {
+ domGlobals.console.error('HTML does not have a single root node', html);
+ throw new Error('HTML must have a single root node');
+ }
+ return fromDom(div.childNodes[0]);
+ };
+ var fromTag = function (tag, scope) {
+ var doc = scope || domGlobals.document;
+ var node = doc.createElement(tag);
+ return fromDom(node);
+ };
+ var fromText = function (text, scope) {
+ var doc = scope || domGlobals.document;
+ var node = doc.createTextNode(text);
+ return fromDom(node);
+ };
+ var fromDom = function (node) {
+ if (node === null || node === undefined) {
+ throw new Error('Node cannot be null or undefined');
+ }
+ return { dom: constant(node) };
+ };
+ var fromPoint = function (docElm, x, y) {
+ var doc = docElm.dom();
+ return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
+ };
+ var Element = {
+ fromHtml: fromHtml,
+ fromTag: fromTag,
+ fromText: fromText,
+ fromDom: fromDom,
+ fromPoint: fromPoint
+ };
+
+ var liftN = function (arr, f) {
+ var r = [];
+ for (var i = 0; i < arr.length; i++) {
+ var x = arr[i];
+ if (x.isSome()) {
+ r.push(x.getOrDie());
+ } else {
+ return Option.none();
+ }
+ }
+ return Option.some(f.apply(null, r));
+ };
+
+ var fromElements = function (elements, scope) {
+ var doc = scope || domGlobals.document;
+ var fragment = doc.createDocumentFragment();
+ each(elements, function (element) {
+ fragment.appendChild(element.dom());
+ });
+ return Element.fromDom(fragment);
+ };
+
+ var Immutable = function () {
+ var fields = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ fields[_i] = arguments[_i];
+ }
+ return function () {
+ var values = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ values[_i] = arguments[_i];
+ }
+ if (fields.length !== values.length) {
+ throw new Error('Wrong number of arguments to struct. Expected "[' + fields.length + ']", got ' + values.length + ' arguments');
+ }
+ var struct = {};
+ each(fields, function (name, i) {
+ struct[name] = constant(values[i]);
+ });
+ return struct;
+ };
+ };
+
+ var keys = Object.keys;
+ var each$1 = function (obj, f) {
+ var props = keys(obj);
+ for (var k = 0, len = props.length; k < len; k++) {
+ var i = props[k];
+ var x = obj[i];
+ f(x, i, obj);
+ }
+ };
+
+ var node = function () {
+ var f = Global$1.getOrDie('Node');
+ return f;
+ };
+ var compareDocumentPosition = function (a, b, match) {
+ return (a.compareDocumentPosition(b) & match) !== 0;
+ };
+ var documentPositionPreceding = function (a, b) {
+ return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_PRECEDING);
+ };
+ var documentPositionContainedBy = function (a, b) {
+ return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY);
+ };
+ var Node = {
+ documentPositionPreceding: documentPositionPreceding,
+ documentPositionContainedBy: documentPositionContainedBy
+ };
+
+ var cached = function (f) {
+ var called = false;
+ var r;
+ return function () {
+ var args = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ args[_i] = arguments[_i];
+ }
+ if (!called) {
+ called = true;
+ r = f.apply(null, args);
+ }
+ return r;
+ };
+ };
+
+ var firstMatch = function (regexes, s) {
+ for (var i = 0; i < regexes.length; i++) {
+ var x = regexes[i];
+ if (x.test(s))
+ return x;
+ }
+ return undefined;
+ };
+ var find$1 = function (regexes, agent) {
+ var r = firstMatch(regexes, agent);
+ if (!r)
+ return {
+ major: 0,
+ minor: 0
+ };
+ var group = function (i) {
+ return Number(agent.replace(r, '$' + i));
+ };
+ return nu(group(1), group(2));
+ };
+ var detect = function (versionRegexes, agent) {
+ var cleanedAgent = String(agent).toLowerCase();
+ if (versionRegexes.length === 0)
+ return unknown();
+ return find$1(versionRegexes, cleanedAgent);
+ };
+ var unknown = function () {
+ return nu(0, 0);
+ };
+ var nu = function (major, minor) {
+ return {
+ major: major,
+ minor: minor
+ };
+ };
+ var Version = {
+ nu: nu,
+ detect: detect,
+ unknown: unknown
+ };
+
+ var edge = 'Edge';
+ var chrome = 'Chrome';
+ var ie = 'IE';
+ var opera = 'Opera';
+ var firefox = 'Firefox';
+ var safari = 'Safari';
+ var isBrowser = function (name, current) {
+ return function () {
+ return current === name;
+ };
+ };
+ var unknown$1 = function () {
+ return nu$1({
+ current: undefined,
+ version: Version.unknown()
+ });
+ };
+ var nu$1 = function (info) {
+ var current = info.current;
+ var version = info.version;
+ return {
+ current: current,
+ version: version,
+ isEdge: isBrowser(edge, current),
+ isChrome: isBrowser(chrome, current),
+ isIE: isBrowser(ie, current),
+ isOpera: isBrowser(opera, current),
+ isFirefox: isBrowser(firefox, current),
+ isSafari: isBrowser(safari, current)
+ };
+ };
+ var Browser = {
+ unknown: unknown$1,
+ nu: nu$1,
+ edge: constant(edge),
+ chrome: constant(chrome),
+ ie: constant(ie),
+ opera: constant(opera),
+ firefox: constant(firefox),
+ safari: constant(safari)
+ };
+
+ var windows = 'Windows';
+ var ios = 'iOS';
+ var android = 'Android';
+ var linux = 'Linux';
+ var osx = 'OSX';
+ var solaris = 'Solaris';
+ var freebsd = 'FreeBSD';
+ var isOS = function (name, current) {
+ return function () {
+ return current === name;
+ };
+ };
+ var unknown$2 = function () {
+ return nu$2({
+ current: undefined,
+ version: Version.unknown()
+ });
+ };
+ var nu$2 = function (info) {
+ var current = info.current;
+ var version = info.version;
+ return {
+ current: current,
+ version: version,
+ isWindows: isOS(windows, current),
+ isiOS: isOS(ios, current),
+ isAndroid: isOS(android, current),
+ isOSX: isOS(osx, current),
+ isLinux: isOS(linux, current),
+ isSolaris: isOS(solaris, current),
+ isFreeBSD: isOS(freebsd, current)
+ };
+ };
+ var OperatingSystem = {
+ unknown: unknown$2,
+ nu: nu$2,
+ windows: constant(windows),
+ ios: constant(ios),
+ android: constant(android),
+ linux: constant(linux),
+ osx: constant(osx),
+ solaris: constant(solaris),
+ freebsd: constant(freebsd)
+ };
+
+ var DeviceType = function (os, browser, userAgent) {
+ var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
+ var isiPhone = os.isiOS() && !isiPad;
+ var isAndroid3 = os.isAndroid() && os.version.major === 3;
+ var isAndroid4 = os.isAndroid() && os.version.major === 4;
+ var isTablet = isiPad || isAndroid3 || isAndroid4 && /mobile/i.test(userAgent) === true;
+ var isTouch = os.isiOS() || os.isAndroid();
+ var isPhone = isTouch && !isTablet;
+ var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
+ return {
+ isiPad: constant(isiPad),
+ isiPhone: constant(isiPhone),
+ isTablet: constant(isTablet),
+ isPhone: constant(isPhone),
+ isTouch: constant(isTouch),
+ isAndroid: os.isAndroid,
+ isiOS: os.isiOS,
+ isWebView: constant(iOSwebview)
+ };
+ };
+
+ var detect$1 = function (candidates, userAgent) {
+ var agent = String(userAgent).toLowerCase();
+ return find(candidates, function (candidate) {
+ return candidate.search(agent);
+ });
+ };
+ var detectBrowser = function (browsers, userAgent) {
+ return detect$1(browsers, userAgent).map(function (browser) {
+ var version = Version.detect(browser.versionRegexes, userAgent);
+ return {
+ current: browser.name,
+ version: version
+ };
+ });
+ };
+ var detectOs = function (oses, userAgent) {
+ return detect$1(oses, userAgent).map(function (os) {
+ var version = Version.detect(os.versionRegexes, userAgent);
+ return {
+ current: os.name,
+ version: version
+ };
+ });
+ };
+ var UaString = {
+ detectBrowser: detectBrowser,
+ detectOs: detectOs
+ };
+
+ var contains = function (str, substr) {
+ return str.indexOf(substr) !== -1;
+ };
+
+ var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
+ var checkContains = function (target) {
+ return function (uastring) {
+ return contains(uastring, target);
+ };
+ };
+ var browsers = [
+ {
+ name: 'Edge',
+ versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
+ search: function (uastring) {
+ var monstrosity = contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
+ return monstrosity;
+ }
+ },
+ {
+ name: 'Chrome',
+ versionRegexes: [
+ /.*?chrome\/([0-9]+)\.([0-9]+).*/,
+ normalVersionRegex
+ ],
+ search: function (uastring) {
+ return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
+ }
+ },
+ {
+ name: 'IE',
+ versionRegexes: [
+ /.*?msie\ ?([0-9]+)\.([0-9]+).*/,
+ /.*?rv:([0-9]+)\.([0-9]+).*/
+ ],
+ search: function (uastring) {
+ return contains(uastring, 'msie') || contains(uastring, 'trident');
+ }
+ },
+ {
+ name: 'Opera',
+ versionRegexes: [
+ normalVersionRegex,
+ /.*?opera\/([0-9]+)\.([0-9]+).*/
+ ],
+ search: checkContains('opera')
+ },
+ {
+ name: 'Firefox',
+ versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
+ search: checkContains('firefox')
+ },
+ {
+ name: 'Safari',
+ versionRegexes: [
+ normalVersionRegex,
+ /.*?cpu os ([0-9]+)_([0-9]+).*/
+ ],
+ search: function (uastring) {
+ return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
+ }
+ }
+ ];
+ var oses = [
+ {
+ name: 'Windows',
+ search: checkContains('win'),
+ versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
+ },
+ {
+ name: 'iOS',
+ search: function (uastring) {
+ return contains(uastring, 'iphone') || contains(uastring, 'ipad');
+ },
+ versionRegexes: [
+ /.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
+ /.*cpu os ([0-9]+)_([0-9]+).*/,
+ /.*cpu iphone os ([0-9]+)_([0-9]+).*/
+ ]
+ },
+ {
+ name: 'Android',
+ search: checkContains('android'),
+ versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
+ },
+ {
+ name: 'OSX',
+ search: checkContains('os x'),
+ versionRegexes: [/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]
+ },
+ {
+ name: 'Linux',
+ search: checkContains('linux'),
+ versionRegexes: []
+ },
+ {
+ name: 'Solaris',
+ search: checkContains('sunos'),
+ versionRegexes: []
+ },
+ {
+ name: 'FreeBSD',
+ search: checkContains('freebsd'),
+ versionRegexes: []
+ }
+ ];
+ var PlatformInfo = {
+ browsers: constant(browsers),
+ oses: constant(oses)
+ };
+
+ var detect$2 = function (userAgent) {
+ var browsers = PlatformInfo.browsers();
+ var oses = PlatformInfo.oses();
+ var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu);
+ var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
+ var deviceType = DeviceType(os, browser, userAgent);
+ return {
+ browser: browser,
+ os: os,
+ deviceType: deviceType
+ };
+ };
+ var PlatformDetection = { detect: detect$2 };
+
+ var detect$3 = cached(function () {
+ var userAgent = domGlobals.navigator.userAgent;
+ return PlatformDetection.detect(userAgent);
+ });
+ var PlatformDetection$1 = { detect: detect$3 };
+
+ var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE;
+ var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE;
+ var COMMENT = domGlobals.Node.COMMENT_NODE;
+ var DOCUMENT = domGlobals.Node.DOCUMENT_NODE;
+ var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE;
+ var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE;
+ var ELEMENT = domGlobals.Node.ELEMENT_NODE;
+ var TEXT = domGlobals.Node.TEXT_NODE;
+ var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE;
+ var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE;
+ var ENTITY = domGlobals.Node.ENTITY_NODE;
+ var NOTATION = domGlobals.Node.NOTATION_NODE;
+
+ var ELEMENT$1 = ELEMENT;
+ var is = function (element, selector) {
+ var elem = element.dom();
+ if (elem.nodeType !== ELEMENT$1) {
+ return false;
+ } else if (elem.matches !== undefined) {
+ return elem.matches(selector);
+ } else if (elem.msMatchesSelector !== undefined) {
+ return elem.msMatchesSelector(selector);
+ } else if (elem.webkitMatchesSelector !== undefined) {
+ return elem.webkitMatchesSelector(selector);
+ } else if (elem.mozMatchesSelector !== undefined) {
+ return elem.mozMatchesSelector(selector);
+ } else {
+ throw new Error('Browser lacks native selectors');
+ }
+ };
+
+ var eq = function (e1, e2) {
+ return e1.dom() === e2.dom();
+ };
+ var regularContains = function (e1, e2) {
+ var d1 = e1.dom();
+ var d2 = e2.dom();
+ return d1 === d2 ? false : d1.contains(d2);
+ };
+ var ieContains = function (e1, e2) {
+ return Node.documentPositionContainedBy(e1.dom(), e2.dom());
+ };
+ var browser = PlatformDetection$1.detect().browser;
+ var contains$1 = browser.isIE() ? ieContains : regularContains;
+ var is$1 = is;
+
+ var parent = function (element) {
+ var dom = element.dom();
+ return Option.from(dom.parentNode).map(Element.fromDom);
+ };
+ var children = function (element) {
+ var dom = element.dom();
+ return map(dom.childNodes, Element.fromDom);
+ };
+ var child = function (element, index) {
+ var cs = element.dom().childNodes;
+ return Option.from(cs[index]).map(Element.fromDom);
+ };
+ var firstChild = function (element) {
+ return child(element, 0);
+ };
+ var lastChild = function (element) {
+ return child(element, element.dom().childNodes.length - 1);
+ };
+ var spot = Immutable('element', 'offset');
+
+ var before = function (marker, element) {
+ var parent$1 = parent(marker);
+ parent$1.each(function (v) {
+ v.dom().insertBefore(element.dom(), marker.dom());
+ });
+ };
+ var append = function (parent, element) {
+ parent.dom().appendChild(element.dom());
+ };
+
+ var before$1 = function (marker, elements) {
+ each(elements, function (x) {
+ before(marker, x);
+ });
+ };
+ var append$1 = function (parent, elements) {
+ each(elements, function (x) {
+ append(parent, x);
+ });
+ };
+
+ var remove = function (element) {
+ var dom = element.dom();
+ if (dom.parentNode !== null) {
+ dom.parentNode.removeChild(dom);
+ }
+ };
+
+ var name = function (element) {
+ var r = element.dom().nodeName;
+ return r.toLowerCase();
+ };
+
+ var rawSet = function (dom, key, value) {
+ if (isString(value) || isBoolean(value) || isNumber(value)) {
+ dom.setAttribute(key, value + '');
+ } else {
+ domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
+ throw new Error('Attribute value was not simple');
+ }
+ };
+ var setAll = function (element, attrs) {
+ var dom = element.dom();
+ each$1(attrs, function (v, k) {
+ rawSet(dom, k, v);
+ });
+ };
+ var clone = function (element) {
+ return foldl(element.dom().attributes, function (acc, attr) {
+ acc[attr.name] = attr.value;
+ return acc;
+ }, {});
+ };
+
+ var isSupported = function (dom) {
+ return dom.style !== undefined;
+ };
+
+ var internalSet = function (dom, property, value) {
+ if (!isString(value)) {
+ domGlobals.console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
+ throw new Error('CSS value must be a string: ' + value);
+ }
+ if (isSupported(dom)) {
+ dom.style.setProperty(property, value);
+ }
+ };
+ var set = function (element, property, value) {
+ var dom = element.dom();
+ internalSet(dom, property, value);
+ };
+
+ var clone$1 = function (original, isDeep) {
+ return Element.fromDom(original.dom().cloneNode(isDeep));
+ };
+ var deep = function (original) {
+ return clone$1(original, true);
+ };
+ var shallowAs = function (original, tag) {
+ var nu = Element.fromTag(tag);
+ var attributes = clone(original);
+ setAll(nu, attributes);
+ return nu;
+ };
+ var mutate = function (original, tag) {
+ var nu = shallowAs(original, tag);
+ before(original, nu);
+ var children$1 = children(original);
+ append$1(nu, children$1);
+ remove(original);
+ return nu;
+ };
+
+ var joinSegment = function (parent, child) {
+ append(parent.item, child.list);
+ };
+ var joinSegments = function (segments) {
+ for (var i = 1; i < segments.length; i++) {
+ joinSegment(segments[i - 1], segments[i]);
+ }
+ };
+ var appendSegments = function (head$1, tail) {
+ liftN([
+ last(head$1),
+ head(tail)
+ ], joinSegment);
+ };
+ var createSegment = function (scope, listType) {
+ var segment = {
+ list: Element.fromTag(listType, scope),
+ item: Element.fromTag('li', scope)
+ };
+ append(segment.list, segment.item);
+ return segment;
+ };
+ var createSegments = function (scope, entry, size) {
+ var segments = [];
+ for (var i = 0; i < size; i++) {
+ segments.push(createSegment(scope, entry.listType));
+ }
+ return segments;
+ };
+ var populateSegments = function (segments, entry) {
+ for (var i = 0; i < segments.length - 1; i++) {
+ set(segments[i].item, 'list-style-type', 'none');
+ }
+ last(segments).each(function (segment) {
+ setAll(segment.list, entry.listAttributes);
+ setAll(segment.item, entry.itemAttributes);
+ append$1(segment.item, entry.content);
+ });
+ };
+ var normalizeSegment = function (segment, entry) {
+ if (name(segment.list) !== entry.listType) {
+ segment.list = mutate(segment.list, entry.listType);
+ }
+ setAll(segment.list, entry.listAttributes);
+ };
+ var createItem = function (scope, attr, content) {
+ var item = Element.fromTag('li', scope);
+ setAll(item, attr);
+ append$1(item, content);
+ return item;
+ };
+ var appendItem = function (segment, item) {
+ append(segment.list, item);
+ segment.item = item;
+ };
+ var writeShallow = function (scope, cast, entry) {
+ var newCast = cast.slice(0, entry.depth);
+ last(newCast).each(function (segment) {
+ var item = createItem(scope, entry.itemAttributes, entry.content);
+ appendItem(segment, item);
+ normalizeSegment(segment, entry);
+ });
+ return newCast;
+ };
+ var writeDeep = function (scope, cast, entry) {
+ var segments = createSegments(scope, entry, entry.depth - cast.length);
+ joinSegments(segments);
+ populateSegments(segments, entry);
+ appendSegments(cast, segments);
+ return cast.concat(segments);
+ };
+ var composeList = function (scope, entries) {
+ var cast = foldl(entries, function (cast, entry) {
+ return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
+ }, []);
+ return head(cast).map(function (segment) {
+ return segment.list;
+ });
+ };
+
+ var isList$1 = function (el) {
+ return is$1(el, 'OL,UL');
+ };
+ var hasFirstChildList = function (el) {
+ return firstChild(el).map(isList$1).getOr(false);
+ };
+ var hasLastChildList = function (el) {
+ return lastChild(el).map(isList$1).getOr(false);
+ };
+
+ var isIndented = function (entry) {
+ return entry.depth > 0;
+ };
+ var isSelected = function (entry) {
+ return entry.isSelected;
+ };
+ var cloneItemContent = function (li) {
+ var children$1 = children(li);
+ var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
+ return map(content, deep);
+ };
+ var createEntry = function (li, depth, isSelected) {
+ return parent(li).map(function (list) {
+ return {
+ depth: depth,
+ isSelected: isSelected,
+ content: cloneItemContent(li),
+ itemAttributes: clone(li),
+ listAttributes: clone(list),
+ listType: name(list)
+ };
+ });
+ };
+
+ var indentEntry = function (indentation, entry) {
+ switch (indentation) {
+ case 'Indent':
+ entry.depth++;
+ break;
+ case 'Outdent':
+ entry.depth--;
+ break;
+ case 'Flatten':
+ entry.depth = 0;
+ }
+ };
+
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ var shallow = function (old, nu) {
+ return nu;
+ };
+ var baseMerge = function (merger) {
+ return function () {
+ var objects = new Array(arguments.length);
+ for (var i = 0; i < objects.length; i++)
+ objects[i] = arguments[i];
+ if (objects.length === 0)
+ throw new Error('Can\'t merge zero objects');
+ var ret = {};
+ for (var j = 0; j < objects.length; j++) {
+ var curObject = objects[j];
+ for (var key in curObject)
+ if (hasOwnProperty.call(curObject, key)) {
+ ret[key] = merger(ret[key], curObject[key]);
+ }
+ }
+ return ret;
+ };
+ };
+ var merge = baseMerge(shallow);
+
+ var cloneListProperties = function (target, source) {
+ target.listType = source.listType;
+ target.listAttributes = merge({}, source.listAttributes);
+ };
+ var previousSiblingEntry = function (entries, start) {
+ var depth = entries[start].depth;
+ for (var i = start - 1; i >= 0; i--) {
+ if (entries[i].depth === depth) {
+ return Option.some(entries[i]);
+ }
+ if (entries[i].depth < depth) {
+ break;
+ }
+ }
+ return Option.none();
+ };
+ var normalizeEntries = function (entries) {
+ each(entries, function (entry, i) {
+ previousSiblingEntry(entries, i).each(function (matchingEntry) {
+ cloneListProperties(entry, matchingEntry);
+ });
+ });
+ };
+
+ var Cell = function (initial) {
+ var value = initial;
+ var get = function () {
+ return value;
+ };
+ var set = function (v) {
+ value = v;
+ };
+ var clone = function () {
+ return Cell(get());
+ };
+ return {
+ get: get,
+ set: set,
+ clone: clone
+ };
+ };
+
+ var parseItem = function (depth, itemSelection, selectionState, item) {
+ return firstChild(item).filter(isList$1).fold(function () {
+ itemSelection.each(function (selection) {
+ if (eq(selection.start, item)) {
+ selectionState.set(true);
+ }
+ });
+ var currentItemEntry = createEntry(item, depth, selectionState.get());
+ itemSelection.each(function (selection) {
+ if (eq(selection.end, item)) {
+ selectionState.set(false);
+ }
+ });
+ var childListEntries = lastChild(item).filter(isList$1).map(function (list) {
+ return parseList(depth, itemSelection, selectionState, list);
+ }).getOr([]);
+ return currentItemEntry.toArray().concat(childListEntries);
+ }, function (list) {
+ return parseList(depth, itemSelection, selectionState, list);
+ });
+ };
+ var parseList = function (depth, itemSelection, selectionState, list) {
+ return bind(children(list), function (element) {
+ var parser = isList$1(element) ? parseList : parseItem;
+ var newDepth = depth + 1;
+ return parser(newDepth, itemSelection, selectionState, element);
+ });
+ };
+ var parseLists = function (lists, itemSelection) {
+ var selectionState = Cell(false);
+ var initialDepth = 0;
+ return map(lists, function (list) {
+ return {
+ sourceList: list,
+ entries: parseList(initialDepth, itemSelection, selectionState, list)
+ };
+ });
};
var global$8 = tinymce.util.Tools.resolve('tinymce.Env');
- var DOM$2 = global$6.DOM;
- var createNewTextBlock = function (editor, contentNode, blockName) {
- var node, textBlock;
- var fragment = DOM$2.createFragment();
- var hasContentNode;
+ var createTextBlock = function (editor, contentNode) {
+ var dom = editor.dom;
var blockElements = editor.schema.getBlockElements();
+ var fragment = dom.createFragment();
+ var node, textBlock, blockName, hasContentNode;
if (editor.settings.forced_root_block) {
- blockName = blockName || editor.settings.forced_root_block;
+ blockName = editor.settings.forced_root_block;
}
if (blockName) {
- textBlock = DOM$2.create(blockName);
+ textBlock = dom.create(blockName);
if (textBlock.tagName === editor.settings.forced_root_block) {
- DOM$2.setAttribs(textBlock, editor.settings.forced_root_block_attrs);
+ dom.setAttribs(textBlock, editor.settings.forced_root_block_attrs);
}
if (!NodeType.isBlock(contentNode.firstChild, blockElements)) {
fragment.appendChild(textBlock);
@@ -295,7 +1431,7 @@
} else {
if (blockName) {
if (!textBlock) {
- textBlock = DOM$2.create(blockName);
+ textBlock = dom.create(blockName);
fragment.appendChild(textBlock);
}
textBlock.appendChild(node);
@@ -306,153 +1442,139 @@
}
}
if (!editor.settings.forced_root_block) {
- fragment.appendChild(DOM$2.create('br'));
+ fragment.appendChild(dom.create('br'));
} else {
if (!hasContentNode && (!global$8.ie || global$8.ie > 10)) {
- textBlock.appendChild(DOM$2.create('br', { 'data-mce-bogus': '1' }));
+ textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
}
}
return fragment;
};
- var TextBlock = { createNewTextBlock: createNewTextBlock };
- var DOM$3 = global$6.DOM;
- var splitList = function (editor, ul, li, newBlock) {
- var tmpRng, fragment, bookmarks, node;
+ var outdentedComposer = function (editor, entries) {
+ return map(entries, function (entry) {
+ var content = fromElements(entry.content);
+ return Element.fromDom(createTextBlock(editor, content.dom()));
+ });
+ };
+ var indentedComposer = function (editor, entries) {
+ normalizeEntries(entries);
+ return composeList(editor.contentDocument, entries).toArray();
+ };
+ var composeEntries = function (editor, entries) {
+ return bind(groupBy(entries, isIndented), function (entries) {
+ var groupIsIndented = head(entries).map(isIndented).getOr(false);
+ return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
+ });
+ };
+ var indentSelectedEntries = function (entries, indentation) {
+ each(filter(entries, isSelected), function (entry) {
+ return indentEntry(indentation, entry);
+ });
+ };
+ var getItemSelection = function (editor) {
+ var selectedListItems = map(Selection.getSelectedListItems(editor), Element.fromDom);
+ return liftN([
+ find(selectedListItems, not(hasFirstChildList)),
+ find(reverse(selectedListItems), not(hasFirstChildList))
+ ], function (start, end) {
+ return {
+ start: start,
+ end: end
+ };
+ });
+ };
+ var listsIndentation = function (editor, lists, indentation) {
+ var entrySets = parseLists(lists, getItemSelection(editor));
+ each(entrySets, function (entrySet) {
+ indentSelectedEntries(entrySet.entries, indentation);
+ before$1(entrySet.sourceList, composeEntries(editor, entrySet.entries));
+ remove(entrySet.sourceList);
+ });
+ };
+
+ var DOM$1 = global$6.DOM;
+ var splitList = function (editor, ul, li) {
+ var tmpRng, fragment, bookmarks, node, newBlock;
var removeAndKeepBookmarks = function (targetNode) {
global$5.each(bookmarks, function (node) {
targetNode.parentNode.insertBefore(node, li.parentNode);
});
- DOM$3.remove(targetNode);
+ DOM$1.remove(targetNode);
};
- bookmarks = DOM$3.select('span[data-mce-type="bookmark"]', ul);
- newBlock = newBlock || TextBlock.createNewTextBlock(editor, li);
- tmpRng = DOM$3.createRng();
+ bookmarks = DOM$1.select('span[data-mce-type="bookmark"]', ul);
+ newBlock = createTextBlock(editor, li);
+ tmpRng = DOM$1.createRng();
tmpRng.setStartAfter(li);
tmpRng.setEndAfter(ul);
fragment = tmpRng.extractContents();
for (node = fragment.firstChild; node; node = node.firstChild) {
if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
- DOM$3.remove(node);
+ DOM$1.remove(node);
break;
}
}
if (!editor.dom.isEmpty(fragment)) {
- DOM$3.insertAfter(fragment, ul);
+ DOM$1.insertAfter(fragment, ul);
}
- DOM$3.insertAfter(newBlock, ul);
+ DOM$1.insertAfter(newBlock, ul);
if (NodeType.isEmpty(editor.dom, li.parentNode)) {
removeAndKeepBookmarks(li.parentNode);
}
- DOM$3.remove(li);
+ DOM$1.remove(li);
if (NodeType.isEmpty(editor.dom, ul)) {
- DOM$3.remove(ul);
+ DOM$1.remove(ul);
}
};
var SplitList = { splitList: splitList };
- var DOM$4 = global$6.DOM;
- var removeEmptyLi = function (dom, li) {
- if (NodeType.isEmpty(dom, li)) {
- DOM$4.remove(li);
+ var outdentDlItem = function (editor, item) {
+ if (is$1(item, 'DD')) {
+ mutate(item, 'DT');
+ } else if (is$1(item, 'DT')) {
+ parent(item).each(function (dl) {
+ return SplitList.splitList(editor, dl.dom(), item.dom());
+ });
}
};
- var outdent = function (editor, li) {
- var ul = li.parentNode;
- var ulParent, newBlock;
- if (ul) {
- ulParent = ul.parentNode;
- } else {
- removeEmptyLi(editor.dom, li);
- return true;
- }
- if (ul === editor.getBody()) {
- return true;
+ var indentDlItem = function (item) {
+ if (is$1(item, 'DT')) {
+ mutate(item, 'DD');
}
- if (li.nodeName === 'DD') {
- DOM$4.rename(li, 'DT');
- return true;
- }
- if (NodeType.isFirstChild(li) && NodeType.isLastChild(li)) {
- if (ulParent.nodeName === 'LI') {
- DOM$4.insertAfter(li, ulParent);
- removeEmptyLi(editor.dom, ulParent);
- DOM$4.remove(ul);
- } else if (NodeType.isListNode(ulParent)) {
- DOM$4.remove(ul, true);
- } else {
- ulParent.insertBefore(TextBlock.createNewTextBlock(editor, li), ul);
- DOM$4.remove(ul);
- }
- return true;
- } else if (NodeType.isFirstChild(li)) {
- if (ulParent.nodeName === 'LI') {
- DOM$4.insertAfter(li, ulParent);
- li.appendChild(ul);
- removeEmptyLi(editor.dom, ulParent);
- } else if (NodeType.isListNode(ulParent)) {
- ulParent.insertBefore(li, ul);
- } else {
- ulParent.insertBefore(TextBlock.createNewTextBlock(editor, li), ul);
- DOM$4.remove(li);
- }
- return true;
- } else if (NodeType.isLastChild(li)) {
- if (ulParent.nodeName === 'LI') {
- DOM$4.insertAfter(li, ulParent);
- } else if (NodeType.isListNode(ulParent)) {
- DOM$4.insertAfter(li, ul);
- } else {
- DOM$4.insertAfter(TextBlock.createNewTextBlock(editor, li), ul);
- DOM$4.remove(li);
- }
- return true;
- }
- if (ulParent.nodeName === 'LI') {
- ul = ulParent;
- newBlock = TextBlock.createNewTextBlock(editor, li, 'LI');
- } else if (NodeType.isListNode(ulParent)) {
- newBlock = TextBlock.createNewTextBlock(editor, li, 'LI');
+ };
+ var dlIndentation = function (editor, indentation, dlItems) {
+ if (indentation === 'Indent') {
+ each(dlItems, indentDlItem);
} else {
- newBlock = TextBlock.createNewTextBlock(editor, li);
+ each(dlItems, function (item) {
+ return outdentDlItem(editor, item);
+ });
}
- SplitList.splitList(editor, ul, li, newBlock);
- NormalizeLists.normalizeLists(editor.dom, ul.parentNode);
- return true;
};
- var outdentSelection = function (editor) {
- var listElements = Selection.getSelectedListItems(editor);
- if (listElements.length) {
- var bookmark = Bookmark.createBookmark(editor.selection.getRng());
- var i = void 0, y = void 0;
- var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
- i = listElements.length;
- while (i--) {
- var node = listElements[i].parentNode;
- while (node && node !== root) {
- y = listElements.length;
- while (y--) {
- if (listElements[y] === node) {
- listElements.splice(i, 1);
- break;
- }
- }
- node = node.parentNode;
- }
- }
- for (i = 0; i < listElements.length; i++) {
- if (!outdent(editor, listElements[i]) && i === 0) {
- break;
- }
- }
- editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
+
+ var selectionIndentation = function (editor, indentation) {
+ var lists = map(Selection.getSelectedListRoots(editor), Element.fromDom);
+ var dlItems = map(Selection.getSelectedDlItems(editor), Element.fromDom);
+ var isHandled = false;
+ if (lists.length || dlItems.length) {
+ var bookmark = editor.selection.getBookmark();
+ listsIndentation(editor, lists, indentation);
+ dlIndentation(editor, indentation, dlItems);
+ editor.selection.moveToBookmark(bookmark);
+ editor.selection.setRng(Range.normalizeRange(editor.selection.getRng()));
editor.nodeChanged();
- return true;
+ isHandled = true;
}
+ return isHandled;
+ };
+ var indentListSelection = function (editor) {
+ return selectionIndentation(editor, 'Indent');
};
- var Outdent = {
- outdent: outdent,
- outdentSelection: outdentSelection
+ var outdentListSelection = function (editor) {
+ return selectionIndentation(editor, 'Outdent');
+ };
+ var flattenListSelection = function (editor) {
+ return selectionIndentation(editor, 'Flatten');
};
var updateListStyle = function (dom, el, detail) {
@@ -595,37 +1717,6 @@
});
editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
};
- var removeList = function (editor) {
- var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
- var root = Selection.getClosestListRootElm(editor, editor.selection.getStart(true));
- var listItems = Selection.getSelectedListItems(editor);
- var emptyListItems = global$5.grep(listItems, function (li) {
- return editor.dom.isEmpty(li);
- });
- listItems = global$5.grep(listItems, function (li) {
- return !editor.dom.isEmpty(li);
- });
- global$5.each(emptyListItems, function (li) {
- if (NodeType.isEmpty(editor.dom, li)) {
- Outdent.outdent(editor, li);
- return;
- }
- });
- global$5.each(listItems, function (li) {
- var node, rootList;
- if (li.parentNode === editor.getBody()) {
- return;
- }
- for (node = li; node && node !== root; node = node.parentNode) {
- if (NodeType.isListNode(node)) {
- rootList = node;
- }
- }
- SplitList.splitList(editor, rootList, li);
- NormalizeLists.normalizeLists(editor.dom, rootList.parentNode);
- });
- editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
- };
var isValidLists = function (list1, list2) {
return list1 && list2 && NodeType.isListNode(list1) && list1.nodeName === list2.nodeName;
};
@@ -667,7 +1758,7 @@
};
var toggleMultipleLists = function (editor, parentList, lists, listName, detail) {
if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
- removeList(editor);
+ flattenListSelection(editor);
} else {
var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
global$5.each([parentList].concat(lists), function (elm) {
@@ -685,7 +1776,7 @@
}
if (parentList) {
if (parentList.nodeName === listName && !hasListStyleDetail(detail)) {
- removeList(editor);
+ flattenListSelection(editor);
} else {
var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
updateListWithDetails(editor.dom, parentList, detail);
@@ -708,10 +1799,41 @@
};
var ToggleList = {
toggleList: toggleList,
- removeList: removeList,
mergeWithAdjacentLists: mergeWithAdjacentLists
};
+ var DOM$2 = global$6.DOM;
+ var normalizeList = function (dom, ul) {
+ var sibling;
+ var parentNode = ul.parentNode;
+ if (parentNode.nodeName === 'LI' && parentNode.firstChild === ul) {
+ sibling = parentNode.previousSibling;
+ if (sibling && sibling.nodeName === 'LI') {
+ sibling.appendChild(ul);
+ if (NodeType.isEmpty(dom, parentNode)) {
+ DOM$2.remove(parentNode);
+ }
+ } else {
+ DOM$2.setStyle(parentNode, 'listStyleType', 'none');
+ }
+ }
+ if (NodeType.isListNode(parentNode)) {
+ sibling = parentNode.previousSibling;
+ if (sibling && sibling.nodeName === 'LI') {
+ sibling.appendChild(ul);
+ }
+ }
+ };
+ var normalizeLists = function (dom, element) {
+ global$5.each(global$5.grep(dom.select('ol,ul', element)), function (ul) {
+ normalizeList(dom, ul);
+ });
+ };
+ var NormalizeLists = {
+ normalizeList: normalizeList,
+ normalizeLists: normalizeLists
+ };
+
var findNextCaretContainer = function (editor, rng, isForward, root) {
var node = rng.startContainer;
var offset = rng.startOffset;
@@ -785,10 +1907,14 @@
if (listNode) {
toElm.appendChild(listNode);
}
+ var contains = contains$1(Element.fromDom(toElm), Element.fromDom(fromElm));
+ var nestedLists = contains ? dom.getParents(fromElm, NodeType.isListNode, toElm) : [];
dom.remove(fromElm);
- if (NodeType.isEmpty(dom, ul) && ul !== dom.getRoot()) {
- dom.remove(ul);
+ each(nestedLists, function (list) {
+ if (NodeType.isEmpty(dom, list) && list !== dom.getRoot()) {
+ dom.remove(list);
}
+ });
};
var mergeIntoEmptyLi = function (editor, fromLi, toLi) {
editor.dom.$(toLi).empty();
@@ -833,7 +1959,7 @@
return true;
} else if (!otherLi) {
if (!isForward) {
- ToggleList.removeList(editor);
+ flattenListSelection(editor);
return true;
}
}
@@ -913,67 +2039,6 @@
};
var Api = { get: get };
- var DOM$5 = global$6.DOM;
- var mergeLists = function (from, to) {
- var node;
- if (NodeType.isListNode(from)) {
- while (node = from.firstChild) {
- to.appendChild(node);
- }
- DOM$5.remove(from);
- }
- };
- var indent = function (li) {
- var sibling, newList, listStyle;
- if (li.nodeName === 'DT') {
- DOM$5.rename(li, 'DD');
- return true;
- }
- sibling = li.previousSibling;
- if (sibling && NodeType.isListNode(sibling)) {
- sibling.appendChild(li);
- return true;
- }
- if (sibling && sibling.nodeName === 'LI' && NodeType.isListNode(sibling.lastChild)) {
- sibling.lastChild.appendChild(li);
- mergeLists(li.lastChild, sibling.lastChild);
- return true;
- }
- sibling = li.nextSibling;
- if (sibling && NodeType.isListNode(sibling)) {
- sibling.insertBefore(li, sibling.firstChild);
- return true;
- }
- sibling = li.previousSibling;
- if (sibling && sibling.nodeName === 'LI') {
- newList = DOM$5.create(li.parentNode.nodeName);
- listStyle = DOM$5.getStyle(li.parentNode, 'listStyleType');
- if (listStyle) {
- DOM$5.setStyle(newList, 'listStyleType', listStyle);
- }
- sibling.appendChild(newList);
- newList.appendChild(li);
- mergeLists(li.lastChild, newList);
- return true;
- }
- return false;
- };
- var indentSelection = function (editor) {
- var listElements = Selection.getSelectedListItems(editor);
- if (listElements.length) {
- var bookmark = Bookmark.createBookmark(editor.selection.getRng(true));
- for (var i = 0; i < listElements.length; i++) {
- if (!indent(listElements[i]) && i === 0) {
- break;
- }
- }
- editor.selection.setRng(Bookmark.resolveBookmark(bookmark));
- editor.nodeChanged();
- return true;
- }
- };
- var Indent = { indentSelection: indentSelection };
-
var queryListCommandState = function (editor, listName) {
return function () {
var parentList = editor.dom.getParent(editor.selection.getStart(), 'UL,OL,DL');
@@ -983,20 +2048,10 @@
var register = function (editor) {
editor.on('BeforeExecCommand', function (e) {
var cmd = e.command.toLowerCase();
- var isHandled;
if (cmd === 'indent') {
- if (Indent.indentSelection(editor)) {
- isHandled = true;
- }
+ indentListSelection(editor);
} else if (cmd === 'outdent') {
- if (Outdent.outdentSelection(editor)) {
- isHandled = true;
- }
- }
- if (isHandled) {
- editor.fire('ExecCommand', { command: e.command });
- e.preventDefault();
- return true;
+ outdentListSelection(editor);
}
});
editor.addCommand('InsertUnorderedList', function (ui, detail) {
@@ -1008,6 +2063,9 @@
editor.addCommand('InsertDefinitionList', function (ui, detail) {
ToggleList.toggleList(editor, 'DL', detail);
});
+ editor.addCommand('RemoveList', function () {
+ flattenListSelection(editor);
+ });
editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL'));
editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL'));
editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
@@ -1024,15 +2082,12 @@
if (e.keyCode !== global$3.TAB || global$3.metaKeyPressed(e)) {
return;
}
- if (editor.dom.getParent(editor.selection.getStart(), 'LI,DT,DD')) {
+ editor.undoManager.transact(function () {
+ if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
e.preventDefault();
- if (e.shiftKey) {
- Outdent.outdentSelection(editor);
- } else {
- Indent.indentSelection(editor);
- }
}
});
+ });
};
var setup$1 = function (editor) {
if (Settings.shouldIndentOnTab(editor)) {
@@ -1062,16 +2117,6 @@
});
};
};
- var indentPostRender = function (editor) {
- return function (e) {
- var ctrl = e.control;
- editor.on('nodechange', function () {
- var listItemBlocks = Selection.getSelectedListItems(editor);
- var disable = listItemBlocks.length > 0 && NodeType.isFirstChild(listItemBlocks[0]);
- ctrl.disabled(disable);
- });
- };
- };
var register$1 = function (editor) {
var hasPlugin = function (editor, plugin) {
var plugins = editor.settings.plugins ? editor.settings.plugins : '';
@@ -1094,8 +2139,7 @@
editor.addButton('indent', {
icon: 'indent',
title: 'Increase indent',
- cmd: 'Indent',
- onPostRender: indentPostRender(editor)
+ cmd: 'Indent'
});
};
var Buttons = { register: register$1 };
@@ -1111,5 +2155,5 @@
return Plugin;
-}());
+}(window));
})();

plugins/lists/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),d=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),l=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),n=tinymce.util.Tools.resolve("tinymce.util.VK"),p=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),o=function(e){return e&&"BR"===e.nodeName},r=function(e){return e&&3===e.nodeType},h=function(e){return e&&/^(OL|UL|DL)$/.test(e.nodeName)},i=function(e){return e&&/^(LI|DT|DD)$/.test(e.nodeName)},a=function(e){return e&&/^(TH|TD)$/.test(e.nodeName)},C=o,s=function(e){return e.parentNode.firstChild===e},c=function(e){return e.parentNode.lastChild===e},y=function(e,t){return t&&!!e.schema.getTextBlockElements()[t.nodeName]},f=function(e,t){return e&&e.nodeName in t},u=function(e,t){return!!o(t)&&!(!e.isBlock(t.nextSibling)||o(t.previousSibling))},m=function(e,t,n){var o=e.isEmpty(t);return!(n&&0<e.select("span[data-mce-type=bookmark]",t).length)&&o},g=function(e,t){return e.isChildOf(t,e.getRoot())},N=function(e,t){var n=d.getNode(e,t);return i(e)&&r(n)?{container:n,offset:t>=e.childNodes.length?n.data.length:0}:{container:e,offset:t}},L=function(e){var t=e.cloneRange(),n=N(e.startContainer,e.startOffset);t.setStart(n.container,n.offset);var o=N(e.endContainer,e.endOffset);return t.setEnd(o.container,o.offset),t},S=t.DOM,b=function(r){var i={},e=function(e){var t,n,o;n=r[e?"startContainer":"endContainer"],o=r[e?"startOffset":"endOffset"],1===n.nodeType&&(t=S.create("span",{"data-mce-type":"bookmark"}),n.hasChildNodes()?(o=Math.min(o,n.childNodes.length-1),e?n.insertBefore(t,n.childNodes[o]):S.insertAfter(t,n.childNodes[o])):n.appendChild(t),n=t,o=0),i[e?"startContainer":"endContainer"]=n,i[e?"startOffset":"endOffset"]=o};return e(!0),r.collapsed||e(),i},D=function(r){function e(e){var t,n,o;t=o=r[e?"startContainer":"endContainer"],n=r[e?"startOffset":"endOffset"],t&&(1===t.nodeType&&(n=function(e){for(var t=e.parentNode.firstChild,n=0;t;){if(t===e)return n;1===t.nodeType&&"bookmark"===t.getAttribute("data-mce-type")||n++,t=t.nextSibling}return-1}(t),t=t.parentNode,S.remove(o),!t.hasChildNodes()&&S.isBlock(t)&&t.appendChild(S.create("br"))),r[e?"startContainer":"endContainer"]=t,r[e?"startOffset":"endOffset"]=n)}e(!0),e();var t=S.createRng();return t.setStart(r.startContainer,r.startOffset),r.endContainer&&t.setEnd(r.endContainer,r.endOffset),L(t)},k=t.DOM,T=function(e,t){var n,o=t.parentNode;"LI"===o.nodeName&&o.firstChild===t&&((n=o.previousSibling)&&"LI"===n.nodeName?(n.appendChild(t),m(e,o)&&k.remove(o)):k.setStyle(o,"listStyleType","none")),h(o)&&(n=o.previousSibling)&&"LI"===n.nodeName&&n.appendChild(t)},I=function(t,e){v.each(v.grep(t.select("ol,ul",e)),function(e){T(t,e)})},B=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),R=function(e){var t=e.selection.getStart(!0);return e.dom.getParent(t,"OL,UL,DL",O(e,t))},O=function(e,t){var n=e.dom.getParents(t,"TD,TH");return 0<n.length?n[0]:e.getBody()},E={getParentList:R,getSelectedSubLists:function(e){var t,n,o,r=R(e),i=e.selection.getSelectedBlocks();return o=i,(n=r)&&1===o.length&&o[0]===n?(t=r,v.grep(t.querySelectorAll("ol,ul,dl"),function(e){return h(e)})):v.grep(i,function(e){return h(e)&&r!==e})},getSelectedListItems:function(e){var n,t,o,r=e.selection.getSelectedBlocks();return v.grep((n=e,t=r,o=v.map(t,function(e){var t=n.dom.getParent(e,"li,dd,dt",O(n,e));return t||e}),B.unique(o)),function(e){return i(e)})},getClosestListRootElm:O},A=tinymce.util.Tools.resolve("tinymce.Env"),P=t.DOM,x=function(e,t,n){var o,r,i,a=P.createFragment(),s=e.schema.getBlockElements();if(e.settings.forced_root_block&&(n=n||e.settings.forced_root_block),n&&((r=P.create(n)).tagName===e.settings.forced_root_block&&P.setAttribs(r,e.settings.forced_root_block_attrs),f(t.firstChild,s)||a.appendChild(r)),t)for(;o=t.firstChild;){var d=o.nodeName;i||"SPAN"===d&&"bookmark"===o.getAttribute("data-mce-type")||(i=!0),f(o,s)?(a.appendChild(o),r=null):n?(r||(r=P.create(n),a.appendChild(r)),r.appendChild(o)):a.appendChild(o)}return e.settings.forced_root_block?i||A.ie&&!(10<A.ie)||r.appendChild(P.create("br",{"data-mce-bogus":"1"})):a.appendChild(P.create("br")),a},_=t.DOM,M=function(e,t,n,o){var r,i,a,s,d;for(a=_.select('span[data-mce-type="bookmark"]',t),o=o||x(e,n),(r=_.createRng()).setStartAfter(n),r.setEndAfter(t),s=(i=r.extractContents()).firstChild;s;s=s.firstChild)if("LI"===s.nodeName&&e.dom.isEmpty(s)){_.remove(s);break}e.dom.isEmpty(i)||_.insertAfter(i,t),_.insertAfter(o,t),m(e.dom,n.parentNode)&&(d=n.parentNode,v.each(a,function(e){d.parentNode.insertBefore(e,n.parentNode)}),_.remove(d)),_.remove(n),m(e.dom,t)&&_.remove(t)},U=t.DOM,H=function(e,t){m(e,t)&&U.remove(t)},$=function(e,t){var n,o,r=t.parentNode;return r?(n=r.parentNode,r===e.getBody()||("DD"===t.nodeName?U.rename(t,"DT"):s(t)&&c(t)?"LI"===n.nodeName?(U.insertAfter(t,n),H(e.dom,n),U.remove(r)):h(n)?U.remove(r,!0):(n.insertBefore(x(e,t),r),U.remove(r)):s(t)?"LI"===n.nodeName?(U.insertAfter(t,n),t.appendChild(r),H(e.dom,n)):h(n)?n.insertBefore(t,r):(n.insertBefore(x(e,t),r),U.remove(t)):c(t)?"LI"===n.nodeName?U.insertAfter(t,n):h(n)?U.insertAfter(t,r):(U.insertAfter(x(e,t),r),U.remove(t)):("LI"===n.nodeName?(r=n,o=x(e,t,"LI")):o=h(n)?x(e,t,"LI"):x(e,t),M(e,r,t,o),I(e.dom,r.parentNode)))):H(e.dom,t),!0},w=$,K=function(e){var t=E.getSelectedListItems(e);if(t.length){var n=b(e.selection.getRng()),o=void 0,r=void 0,i=E.getClosestListRootElm(e,e.selection.getStart(!0));for(o=t.length;o--;)for(var a=t[o].parentNode;a&&a!==i;){for(r=t.length;r--;)if(t[r]===a){t.splice(o,1);break}a=a.parentNode}for(o=0;o<t.length&&($(e,t[o])||0!==o);o++);return e.selection.setRng(D(n)),e.nodeChanged(),!0}},Q=function(n,e){v.each(e,function(e,t){n.setAttribute(t,e)})},W=function(e,t,n){var o,r,i,a,s,d,l;o=e,r=t,a=(i=n)["list-style-type"]?i["list-style-type"]:null,o.setStyle(r,"list-style-type",a),s=e,Q(d=t,(l=n)["list-attributes"]),v.each(s.select("li",d),function(e){Q(e,l["list-item-attributes"])})},j=function(e,t,n,o){var r,i;for(r=t[n?"startContainer":"endContainer"],i=t[n?"startOffset":"endOffset"],1===r.nodeType&&(r=r.childNodes[Math.min(i,r.childNodes.length-1)]||r),!n&&C(r.nextSibling)&&(r=r.nextSibling);r.parentNode!==o;){if(y(e,r))return r;if(/^(TD|TH)$/.test(r.parentNode.nodeName))return r;r=r.parentNode}return r},q=function(c,f,u){void 0===u&&(u={});var e,t=c.selection.getRng(!0),m="LI",n=E.getClosestListRootElm(c,c.selection.getStart(!0)),g=c.dom;"false"!==g.getContentEditable(c.selection.getNode())&&("DL"===(f=f.toUpperCase())&&(m="DT"),e=b(t),v.each(function(n,e,o){for(var r,i=[],a=n.dom,t=j(n,e,!0,o),s=j(n,e,!1,o),d=[],l=t;l&&(d.push(l),l!==s);l=l.nextSibling);return v.each(d,function(e){if(y(n,e))return i.push(e),void(r=null);if(a.isBlock(e)||C(e))return C(e)&&a.remove(e),void(r=null);var t=e.nextSibling;p.isBookmarkNode(e)&&(y(n,t)||!t&&e.parentNode===o)?r=null:(r||(r=a.create("p"),e.parentNode.insertBefore(r,e),i.push(r)),r.appendChild(e))}),i}(c,t,n),function(e){var t,n,o,r,i,a,s,d,l;(n=e.previousSibling)&&h(n)&&n.nodeName===f&&(o=n,r=u,i=g.getStyle(o,"list-style-type"),a=r?r["list-style-type"]:"",i===(a=null===a?"":a))?(t=n,e=g.rename(e,m),n.appendChild(e)):(t=g.create(f),e.parentNode.insertBefore(t,e),t.appendChild(e),e=g.rename(e,m)),s=g,d=e,l=["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],v.each(l,function(e){var t;return s.setStyle(d,((t={})[e]="",t))}),W(g,t,u),z(c.dom,t)}),c.selection.setRng(D(e)))},F=function(o){var e=b(o.selection.getRng(!0)),r=E.getClosestListRootElm(o,o.selection.getStart(!0)),t=E.getSelectedListItems(o),n=v.grep(t,function(e){return o.dom.isEmpty(e)});t=v.grep(t,function(e){return!o.dom.isEmpty(e)}),v.each(n,function(e){m(o.dom,e)&&w(o,e)}),v.each(t,function(e){var t,n;if(e.parentNode!==o.getBody()){for(t=e;t&&t!==r;t=t.parentNode)h(t)&&(n=t);M(o,n,e),I(o.dom,n.parentNode)}}),o.selection.setRng(D(e))},V=function(e,t,n){return d=n,(s=t)&&d&&h(s)&&s.nodeName===d.nodeName&&(i=t,a=n,(r=e).getStyle(i,"list-style-type",!0)===r.getStyle(a,"list-style-type",!0))&&(o=n,t.className===o.className);var o,r,i,a,s,d},z=function(e,t){var n,o;if(n=t.nextSibling,V(e,t,n)){for(;o=n.firstChild;)t.appendChild(o);e.remove(n)}if(n=t.previousSibling,V(e,t,n)){for(;o=n.lastChild;)t.insertBefore(o,t.firstChild);e.remove(n)}},G=function(t,e,n,o,r){if(e.nodeName!==o||J(r)){var i=b(t.selection.getRng(!0));v.each([e].concat(n),function(e){!function(e,t,n,o){if(t.nodeName!==n){var r=e.rename(t,n);W(e,r,o)}else W(e,t,o)}(t.dom,e,o,r)}),t.selection.setRng(D(i))}else F(t)},J=function(e){return"list-style-type"in e},X={toggleList:function(e,t,n){var o=E.getParentList(e),r=E.getSelectedSubLists(e);n=n||{},o&&0<r.length?G(e,o,r,t,n):function(e,t,n,o){if(t!==e.getBody())if(t)if(t.nodeName!==n||J(o)){var r=b(e.selection.getRng(!0));W(e.dom,t,o),z(e.dom,e.dom.rename(t,n)),e.selection.setRng(D(r))}else F(e);else q(e,n,o)}(e,o,t,n)},removeList:F,mergeWithAdjacentLists:z},Y=function(e,t,n,o){var r,i,a=t.startContainer,s=t.startOffset;if(3===a.nodeType&&(n?s<a.data.length:0<s))return a;for(r=e.schema.getNonEmptyElements(),1===a.nodeType&&(a=d.getNode(a,s)),i=new l(a,o),n&&u(e.dom,a)&&i.next();a=i[n?"next":"prev2"]();){if("LI"===a.nodeName&&!a.hasChildNodes())return a;if(r[a.nodeName])return a;if(3===a.nodeType&&0<a.data.length)return a}},Z=function(e,t){var n=t.childNodes;return 1===n.length&&!h(n[0])&&e.isBlock(n[0])},ee=function(e,t,n){var o,r,i,a;if(r=Z(e,n)?n.firstChild:n,Z(i=e,a=t)&&i.remove(a.firstChild,!0),!m(e,t,!0))for(;o=t.firstChild;)r.appendChild(o)},te=function(e,t,n){var o,r,i=t.parentNode;g(e,t)&&g(e,n)&&(h(n.lastChild)&&(r=n.lastChild),i===n.lastChild&&C(i.previousSibling)&&e.remove(i.previousSibling),(o=n.lastChild)&&C(o)&&t.hasChildNodes()&&e.remove(o),m(e,n,!0)&&e.$(n).empty(),ee(e,t,n),r&&n.appendChild(r),e.remove(t),m(e,i)&&i!==e.getRoot()&&e.remove(i))},ne=function(e,t,n,o){var r,i,a,s=e.dom;if(s.isEmpty(o))i=n,a=o,(r=e).dom.$(a).empty(),te(r.dom,i,a),r.selection.setCursorLocation(a);else{var d=b(t);te(s,n,o),e.selection.setRng(D(d))}},oe=function(e,t){var n,o,r,i=e.dom,a=e.selection,s=a.getStart(),d=E.getClosestListRootElm(e,s),l=i.getParent(a.getStart(),"LI",d);if(l){if((n=l.parentNode)===e.getBody()&&m(i,n))return!0;if(o=L(a.getRng(!0)),(r=i.getParent(Y(e,o,t,d),"LI",d))&&r!==l)return t?ne(e,o,r,l):function(e,t,n,o){var r=b(t);te(e.dom,n,o);var i=D(r);e.selection.setRng(i)}(e,o,l,r),!0;if(!r&&!t)return X.removeList(e),!0}return!1},re=function(e,t){return oe(e,t)||function(r,i){var a=r.dom,e=r.selection.getStart(),s=E.getClosestListRootElm(r,e),d=a.getParent(e,a.isBlock,s);if(d&&a.isEmpty(d)){var t=L(r.selection.getRng(!0)),l=a.getParent(Y(r,t,i,s),"LI",s);if(l)return r.undoManager.transact(function(){var e,t,n,o;t=d,n=s,o=(e=a).getParent(t.parentNode,e.isBlock,n),e.remove(t),o&&e.isEmpty(o)&&e.remove(o),X.mergeWithAdjacentLists(a,l.parentNode),r.selection.select(l,!0),r.selection.collapse(i)}),!0}return!1}(e,t)},ie=function(e,t){return e.selection.isCollapsed()?re(e,t):(o=(n=e).selection.getStart(),r=E.getClosestListRootElm(n,o),!!(n.dom.getParent(o,"LI,DT,DD",r)||0<E.getSelectedListItems(n).length)&&(n.undoManager.transact(function(){n.execCommand("Delete"),I(n.dom,n.getBody())}),!0));var n,o,r},ae=function(t){t.on("keydown",function(e){e.keyCode===n.BACKSPACE?ie(t,!1)&&e.preventDefault():e.keyCode===n.DELETE&&ie(t,!0)&&e.preventDefault()})},se=ie,de=function(t){return{backspaceDelete:function(e){se(t,e)}}},le=t.DOM,ce=function(e,t){var n;if(h(e)){for(;n=e.firstChild;)t.appendChild(n);le.remove(e)}},fe=function(e){var t,n,o,r,i=E.getSelectedListItems(e);if(i.length){for(var a=b(e.selection.getRng(!0)),s=0;s<i.length&&(t=i[s],r=o=n=void 0,("DT"===t.nodeName?(le.rename(t,"DD"),1):(n=t.previousSibling)&&h(n)?(n.appendChild(t),1):n&&"LI"===n.nodeName&&h(n.lastChild)?(n.lastChild.appendChild(t),ce(t.lastChild,n.lastChild),1):(n=t.nextSibling)&&h(n)?(n.insertBefore(t,n.firstChild),1):(n=t.previousSibling)&&"LI"===n.nodeName&&(o=le.create(t.parentNode.nodeName),(r=le.getStyle(t.parentNode,"listStyleType"))&&le.setStyle(o,"listStyleType",r),n.appendChild(o),o.appendChild(t),ce(t.lastChild,o),1))||0!==s);s++);return e.selection.setRng(D(a)),e.nodeChanged(),!0}},ue=function(t,n){return function(){var e=t.dom.getParent(t.selection.getStart(),"UL,OL,DL");return e&&e.nodeName===n}},me=function(o){o.on("BeforeExecCommand",function(e){var t,n=e.command.toLowerCase();if("indent"===n?fe(o)&&(t=!0):"outdent"===n&&K(o)&&(t=!0),t)return o.fire("ExecCommand",{command:e.command}),e.preventDefault(),!0}),o.addCommand("InsertUnorderedList",function(e,t){X.toggleList(o,"UL",t)}),o.addCommand("InsertOrderedList",function(e,t){X.toggleList(o,"OL",t)}),o.addCommand("InsertDefinitionList",function(e,t){X.toggleList(o,"DL",t)}),o.addQueryStateHandler("InsertUnorderedList",ue(o,"UL")),o.addQueryStateHandler("InsertOrderedList",ue(o,"OL")),o.addQueryStateHandler("InsertDefinitionList",ue(o,"DL"))},ge=function(e){return e.getParam("lists_indent_on_tab",!0)},pe=function(e){var t;ge(e)&&(t=e).on("keydown",function(e){e.keyCode!==n.TAB||n.metaKeyPressed(e)||t.dom.getParent(t.selection.getStart(),"LI,DT,DD")&&(e.preventDefault(),e.shiftKey?K(t):fe(t))}),ae(e)},ve=function(t,i){return function(e){var r=e.control;t.on("NodeChange",function(e){var t=function(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n;return-1}(e.parents,a),n=-1!==t?e.parents.slice(0,t):e.parents,o=v.grep(n,h);r.active(0<o.length&&o[0].nodeName===i)})}},he=function(e){var t,n,o,r;n="advlist",o=(t=e).settings.plugins?t.settings.plugins:"",-1===v.inArray(o.split(/[ ,]/),n)&&(e.addButton("numlist",{active:!1,title:"Numbered list",cmd:"InsertOrderedList",onPostRender:ve(e,"OL")}),e.addButton("bullist",{active:!1,title:"Bullet list",cmd:"InsertUnorderedList",onPostRender:ve(e,"UL")})),e.addButton("indent",{icon:"indent",title:"Increase indent",cmd:"Indent",onPostRender:(r=e,function(e){var n=e.control;r.on("nodechange",function(){var e=E.getSelectedListItems(r),t=0<e.length&&s(e[0]);n.disabled(t)})})})};e.add("lists",function(e){return pe(e),he(e),me(e),de(e)})}();
\ No newline at end of file
+!function(u){"use strict";var e,n,t,r,o,i,a,s,c=tinymce.util.Tools.resolve("tinymce.PluginManager"),f=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),d=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),l=tinymce.util.Tools.resolve("tinymce.util.VK"),p=tinymce.util.Tools.resolve("tinymce.dom.BookmarkManager"),v=tinymce.util.Tools.resolve("tinymce.util.Tools"),m=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),g=function(e){return e&&"BR"===e.nodeName},h=function(e){return e&&3===e.nodeType},y=function(e){return e&&/^(OL|UL|DL)$/.test(e.nodeName)},N=function(e){return e&&/^(OL|UL)$/.test(e.nodeName)},S=function(e){return e&&/^(DT|DD)$/.test(e.nodeName)},C=function(e){return e&&/^(LI|DT|DD)$/.test(e.nodeName)},O=function(e){return e&&/^(TH|TD)$/.test(e.nodeName)},b=g,T=function(e,n){return n&&!!e.schema.getTextBlockElements()[n.nodeName]},D=function(e,n){return e&&e.nodeName in n},L=function(e,n){return!!g(n)&&!(!e.isBlock(n.nextSibling)||g(n.previousSibling))},E=function(e,n,t){var r=e.isEmpty(n);return!(t&&0<e.select("span[data-mce-type=bookmark]",n).length)&&r},w=function(e,n){return e.isChildOf(n,e.getRoot())},k=function(e,n){if(h(e))return{container:e,offset:n};var t=f.getNode(e,n);return h(t)?{container:t,offset:n>=e.childNodes.length?t.data.length:0}:t.previousSibling&&h(t.previousSibling)?{container:t.previousSibling,offset:t.previousSibling.data.length}:t.nextSibling&&h(t.nextSibling)?{container:t.nextSibling,offset:0}:{container:e,offset:n}},A=function(e){var n=e.cloneRange(),t=k(e.startContainer,e.startOffset);n.setStart(t.container,t.offset);var r=k(e.endContainer,e.endOffset);return n.setEnd(r.container,r.offset),n},x=m.DOM,R=function(o){var i={},e=function(e){var n,t,r;t=o[e?"startContainer":"endContainer"],r=o[e?"startOffset":"endOffset"],1===t.nodeType&&(n=x.create("span",{"data-mce-type":"bookmark"}),t.hasChildNodes()?(r=Math.min(r,t.childNodes.length-1),e?t.insertBefore(n,t.childNodes[r]):x.insertAfter(n,t.childNodes[r])):t.appendChild(n),t=n,r=0),i[e?"startContainer":"endContainer"]=t,i[e?"startOffset":"endOffset"]=r};return e(!0),o.collapsed||e(),i},I=function(o){function e(e){var n,t,r;n=r=o[e?"startContainer":"endContainer"],t=o[e?"startOffset":"endOffset"],n&&(1===n.nodeType&&(t=function(e){for(var n=e.parentNode.firstChild,t=0;n;){if(n===e)return t;1===n.nodeType&&"bookmark"===n.getAttribute("data-mce-type")||t++,n=n.nextSibling}return-1}(n),n=n.parentNode,x.remove(r),!n.hasChildNodes()&&x.isBlock(n)&&n.appendChild(x.create("br"))),o[e?"startContainer":"endContainer"]=n,o[e?"startOffset":"endOffset"]=t)}e(!0),e();var n=x.createRng();return n.setStart(o.startContainer,o.startOffset),o.endContainer&&n.setEnd(o.endContainer,o.endOffset),A(n)},_=function(e){return function(){return e}},B=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return!t.apply(null,e)}},P=_(!1),M=_(!0),U=P,F=M,j=function(){return H},H=(r={fold:function(e,n){return e()},is:U,isSome:U,isNone:F,getOr:t=function(e){return e},getOrThunk:n=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:t,orThunk:n,map:j,ap:j,each:function(){},bind:j,flatten:j,exists:U,forall:F,filter:j,equals:e=function(e){return e.isNone()},equals_:e,toArray:function(){return[]},toString:_("none()")},Object.freeze&&Object.freeze(r),r),$=function(t){var e=function(){return t},n=function(){return o},r=function(e){return e(t)},o={fold:function(e,n){return n(t)},is:function(e){return t===e},isSome:F,isNone:U,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:n,orThunk:n,map:function(e){return $(e(t))},ap:function(e){return e.fold(j,function(e){return $(e(t))})},each:function(e){e(t)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(t)?o:H},equals:function(e){return e.is(t)},equals_:function(e,n){return e.fold(U,function(e){return n(t,e)})},toArray:function(){return[t]},toString:function(){return"some("+t+")"}};return o},q={some:$,none:j,from:function(e){return null===e||e===undefined?H:$(e)}},W=function(n){return function(e){return function(e){if(null===e)return"null";var n=typeof e;return"object"===n&&Array.prototype.isPrototypeOf(e)?"array":"object"===n&&String.prototype.isPrototypeOf(e)?"string":n}(e)===n}},z=W("string"),K=W("boolean"),V=W("function"),X=W("number"),Q=function(e,n){for(var t=e.length,r=new Array(t),o=0;o<t;o++){var i=e[o];r[o]=n(i,o,e)}return r},Y=function(e,n){for(var t=0,r=e.length;t<r;t++)n(e[t],t,e)},G=function(e,n){for(var t=[],r=0,o=e.length;r<o;r++){var i=e[r];n(i,r,e)&&t.push(i)}return t},J=function(e,n,t){return Y(e,function(e){t=n(t,e)}),t},Z=function(e,n){for(var t=0,r=e.length;t<r;t++){var o=e[t];if(n(o,t,e))return q.some(o)}return q.none()},ee=Array.prototype.push,ne=function(e,n){return function(e){for(var n=[],t=0,r=e.length;t<r;++t){if(!Array.prototype.isPrototypeOf(e[t]))throw new Error("Arr.flatten item "+t+" was not an array, input: "+e);ee.apply(n,e[t])}return n}(Q(e,n))},te=Array.prototype.slice,re=function(e){return 0===e.length?q.none():q.some(e[0])},oe=function(e){return 0===e.length?q.none():q.some(e[e.length-1])},ie=(V(Array.from)&&Array.from,"undefined"!=typeof u.window?u.window:Function("return this;")()),ue=function(e,n){return function(e,n){for(var t=n!==undefined&&null!==n?n:ie,r=0;r<e.length&&t!==undefined&&null!==t;++r)t=t[e[r]];return t}(e.split("."),n)},ae=function(e,n){var t=ue(e,n);if(t===undefined||null===t)throw e+" not available on this browser";return t},se=function(e){var n,t=ue("ownerDocument.defaultView",e);return(n=t,ae("HTMLElement",n)).prototype.isPrototypeOf(e)},ce=tinymce.util.Tools.resolve("tinymce.dom.DomQuery"),fe=function(e){var n=e.selection.getStart(!0);return e.dom.getParent(n,"OL,UL,DL",le(e,n))},de=function(e){var t,n,r,o=e.selection.getSelectedBlocks();return v.grep((t=e,n=o,r=v.map(n,function(e){var n=t.dom.getParent(e,"li,dd,dt",le(t,e));return n||e}),ce.unique(r)),function(e){return C(e)})},le=function(e,n){var t=e.dom.getParents(n,"TD,TH");return 0<t.length?t[0]:e.getBody()},me=function(e,n){var t=e.dom.getParents(n,"ol,ul",le(e,n));return oe(t)},ge=function(n,e){var t=Q(e,function(e){return me(n,e).getOr(e)});return ce.unique(t)},pe={isList:function(e){var n=fe(e);return se(n)},getParentList:fe,getSelectedSubLists:function(e){var n,t,r,o=fe(e),i=e.selection.getSelectedBlocks();return r=i,(t=o)&&1===r.length&&r[0]===t?(n=o,v.grep(n.querySelectorAll("ol,ul,dl"),function(e){return y(e)})):v.grep(i,function(e){return y(e)&&o!==e})},getSelectedListItems:de,getClosestListRootElm:le,getSelectedDlItems:function(e){return G(de(e),S)},getSelectedListRoots:function(e){var n,t,r,o=(t=me(n=e,n.selection.getStart()),r=G(n.selection.getSelectedBlocks(),N),t.toArray().concat(r));return ge(e,o)}},ve=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:_(e)}},he={fromHtml:function(e,n){var t=(n||u.document).createElement("div");if(t.innerHTML=e,!t.hasChildNodes()||1<t.childNodes.length)throw u.console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return ve(t.childNodes[0])},fromTag:function(e,n){var t=(n||u.document).createElement(e);return ve(t)},fromText:function(e,n){var t=(n||u.document).createTextNode(e);return ve(t)},fromDom:ve,fromPoint:function(e,n,t){var r=e.dom();return q.from(r.elementFromPoint(n,t)).map(ve)}},ye=function(e,n){for(var t=[],r=0;r<e.length;r++){var o=e[r];if(!o.isSome())return q.none();t.push(o.getOrDie())}return q.some(n.apply(null,t))},Ne=Object.keys,Se=function(){return ae("Node")},Ce=function(e,n,t){return 0!=(e.compareDocumentPosition(n)&t)},Oe=function(e,n){return Ce(e,n,Se().DOCUMENT_POSITION_CONTAINED_BY)},be=function(e,n){var t=function(e,n){for(var t=0;t<e.length;t++){var r=e[t];if(r.test(n))return r}return undefined}(e,n);if(!t)return{major:0,minor:0};var r=function(e){return Number(n.replace(t,"$"+e))};return De(r(1),r(2))},Te=function(){return De(0,0)},De=function(e,n){return{major:e,minor:n}},Le={nu:De,detect:function(e,n){var t=String(n).toLowerCase();return 0===e.length?Te():be(e,t)},unknown:Te},Ee="Firefox",we=function(e,n){return function(){return n===e}},ke=function(e){var n=e.current;return{current:n,version:e.version,isEdge:we("Edge",n),isChrome:we("Chrome",n),isIE:we("IE",n),isOpera:we("Opera",n),isFirefox:we(Ee,n),isSafari:we("Safari",n)}},Ae={unknown:function(){return ke({current:undefined,version:Le.unknown()})},nu:ke,edge:_("Edge"),chrome:_("Chrome"),ie:_("IE"),opera:_("Opera"),firefox:_(Ee),safari:_("Safari")},xe="Windows",Re="Android",Ie="Solaris",_e="FreeBSD",Be=function(e,n){return function(){return n===e}},Pe=function(e){var n=e.current;return{current:n,version:e.version,isWindows:Be(xe,n),isiOS:Be("iOS",n),isAndroid:Be(Re,n),isOSX:Be("OSX",n),isLinux:Be("Linux",n),isSolaris:Be(Ie,n),isFreeBSD:Be(_e,n)}},Me={unknown:function(){return Pe({current:undefined,version:Le.unknown()})},nu:Pe,windows:_(xe),ios:_("iOS"),android:_(Re),linux:_("Linux"),osx:_("OSX"),solaris:_(Ie),freebsd:_(_e)},Ue=function(e,n){var t=String(n).toLowerCase();return Z(e,function(e){return e.search(t)})},Fe=function(e,t){return Ue(e,t).map(function(e){var n=Le.detect(e.versionRegexes,t);return{current:e.name,version:n}})},je=function(e,t){return Ue(e,t).map(function(e){var n=Le.detect(e.versionRegexes,t);return{current:e.name,version:n}})},He=function(e,n){return-1!==e.indexOf(n)},$e=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,qe=function(n){return function(e){return He(e,n)}},We=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return He(e,"edge/")&&He(e,"chrome")&&He(e,"safari")&&He(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,$e],search:function(e){return He(e,"chrome")&&!He(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return He(e,"msie")||He(e,"trident")}},{name:"Opera",versionRegexes:[$e,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:qe("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:qe("firefox")},{name:"Safari",versionRegexes:[$e,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(He(e,"safari")||He(e,"mobile/"))&&He(e,"applewebkit")}}],ze=[{name:"Windows",search:qe("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return He(e,"iphone")||He(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:qe("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:qe("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:qe("linux"),versionRegexes:[]},{name:"Solaris",search:qe("sunos"),versionRegexes:[]},{name:"FreeBSD",search:qe("freebsd"),versionRegexes:[]}],Ke={browsers:_(We),oses:_(ze)},Ve=function(e){var n,t,r,o,i,u,a,s,c,f,d,l=Ke.browsers(),m=Ke.oses(),g=Fe(l,e).fold(Ae.unknown,Ae.nu),p=je(m,e).fold(Me.unknown,Me.nu);return{browser:g,os:p,deviceType:(t=g,r=e,o=(n=p).isiOS()&&!0===/ipad/i.test(r),i=n.isiOS()&&!o,u=n.isAndroid()&&3===n.version.major,a=n.isAndroid()&&4===n.version.major,s=o||u||a&&!0===/mobile/i.test(r),c=n.isiOS()||n.isAndroid(),f=c&&!s,d=t.isSafari()&&n.isiOS()&&!1===/safari/i.test(r),{isiPad:_(o),isiPhone:_(i),isTablet:_(s),isPhone:_(f),isTouch:_(c),isAndroid:n.isAndroid,isiOS:n.isiOS,isWebView:_(d)})}},Xe={detect:(o=function(){var e=u.navigator.userAgent;return Ve(e)},a=!1,function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return a||(a=!0,i=o.apply(null,e)),i})},Qe=(u.Node.ATTRIBUTE_NODE,u.Node.CDATA_SECTION_NODE,u.Node.COMMENT_NODE,u.Node.DOCUMENT_NODE,u.Node.DOCUMENT_TYPE_NODE,u.Node.DOCUMENT_FRAGMENT_NODE,u.Node.ELEMENT_NODE),Ye=(u.Node.TEXT_NODE,u.Node.PROCESSING_INSTRUCTION_NODE,u.Node.ENTITY_REFERENCE_NODE,u.Node.ENTITY_NODE,u.Node.NOTATION_NODE,Qe),Ge=function(e,n){return e.dom()===n.dom()},Je=Xe.detect().browser.isIE()?function(e,n){return Oe(e.dom(),n.dom())}:function(e,n){var t=e.dom(),r=n.dom();return t!==r&&t.contains(r)},Ze=function(e,n){var t=e.dom();if(t.nodeType!==Ye)return!1;if(t.matches!==undefined)return t.matches(n);if(t.msMatchesSelector!==undefined)return t.msMatchesSelector(n);if(t.webkitMatchesSelector!==undefined)return t.webkitMatchesSelector(n);if(t.mozMatchesSelector!==undefined)return t.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")},en=function(e){var n=e.dom();return q.from(n.parentNode).map(he.fromDom)},nn=function(e){var n=e.dom();return Q(n.childNodes,he.fromDom)},tn=function(e,n){var t=e.dom().childNodes;return q.from(t[n]).map(he.fromDom)},rn=function(e){return tn(e,0)},on=function(e){return tn(e,e.dom().childNodes.length-1)},un=(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n]}("element","offset"),function(n,t){en(n).each(function(e){e.dom().insertBefore(t.dom(),n.dom())})}),an=function(e,n){e.dom().appendChild(n.dom())},sn=function(n,e){Y(e,function(e){an(n,e)})},cn=function(e){var n=e.dom();null!==n.parentNode&&n.parentNode.removeChild(n)},fn=function(e){return e.dom().nodeName.toLowerCase()},dn=function(e,n){var t=e.dom();!function(e,n){for(var t=Ne(e),r=0,o=t.length;r<o;r++){var i=t[r];n(e[i],i,e)}}(n,function(e,n){!function(e,n,t){if(!(z(t)||K(t)||X(t)))throw u.console.error("Invalid call to Attr.set. Key ",n,":: Value ",t,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(n,t+"")}(t,n,e)})},ln=function(e){return J(e.dom().attributes,function(e,n){return e[n.name]=n.value,e},{})},mn=function(e,n,t){if(!z(t))throw u.console.error("Invalid call to CSS.set. Property ",n,":: Value ",t,":: Element ",e),new Error("CSS value must be a string: "+t);e.style!==undefined&&e.style.setProperty(n,t)},gn=function(e){return n=e,t=!0,he.fromDom(n.dom().cloneNode(t));var n,t},pn=function(e,n){var t,r,o,i,u=(t=e,r=n,o=he.fromTag(r),i=ln(t),dn(o,i),o);un(e,u);var a=nn(e);return sn(u,a),cn(e),u},vn=function(e,n){an(e.item,n.list)},hn=function(f,e,d){var n=e.slice(0,d.depth);return oe(n).each(function(e){var n,t,r,o,i,u,a,s,c=(n=f,t=d.itemAttributes,r=d.content,o=he.fromTag("li",n),dn(o,t),sn(o,r),o);u=c,an((i=e).list,u),i.item=u,s=d,fn((a=e).list)!==s.listType&&(a.list=pn(a.list,s.listType)),dn(a.list,s.listAttributes)}),n},yn=function(e,n,t){var r,o=function(e,n,t){for(var r,o,i,u=[],a=0;a<t;a++)u.push((r=e,o=n.listType,i={list:he.fromTag(o,r),item:he.fromTag("li",r)},an(i.list,i.item),i));return u}(e,t,t.depth-n.length);return function(e){for(var n=1;n<e.length;n++)vn(e[n-1],e[n])}(o),function(e,n){for(var t=0;t<e.length-1;t++)r=e[t].item,o="list-style-type",i="none",u=r.dom(),mn(u,o,i);var r,o,i,u;oe(e).each(function(e){dn(e.list,n.listAttributes),dn(e.item,n.itemAttributes),sn(e.item,n.content)})}(o,t),r=o,ye([oe(n),re(r)],vn),n.concat(o)},Nn=function(e){return Ze(e,"OL,UL")},Sn=function(e){return rn(e).map(Nn).getOr(!1)},Cn=function(e){return 0<e.depth},On=function(e){return e.isSelected},bn=function(e){var n=nn(e),t=on(e).map(Nn).getOr(!1)?n.slice(0,-1):n;return Q(t,gn)},Tn=Object.prototype.hasOwnProperty,Dn=(s=function(e,n){return n},function(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];if(0===e.length)throw new Error("Can't merge zero objects");for(var t={},r=0;r<e.length;r++){var o=e[r];for(var i in o)Tn.call(o,i)&&(t[i]=s(t[i],o[i]))}return t}),Ln=function(n){Y(n,function(r,e){(function(e,n){for(var t=e[n].depth,r=n-1;0<=r;r--){if(e[r].depth===t)return q.some(e[r]);if(e[r].depth<t)break}return q.none()})(n,e).each(function(e){var n,t;t=e,(n=r).listType=t.listType,n.listAttributes=Dn({},t.listAttributes)})})},En=function(e){var n=e,t=function(){return n};return{get:t,set:function(e){n=e},clone:function(){return En(t())}}},wn=function(i,u,a,s){return rn(s).filter(Nn).fold(function(){u.each(function(e){Ge(e.start,s)&&a.set(!0)});var n,t,r,e=(n=s,t=i,r=a.get(),en(n).map(function(e){return{depth:t,isSelected:r,content:bn(n),itemAttributes:ln(n),listAttributes:ln(e),listType:fn(e)}}));u.each(function(e){Ge(e.end,s)&&a.set(!1)});var o=on(s).filter(Nn).map(function(e){return kn(i,u,a,e)}).getOr([]);return e.toArray().concat(o)},function(e){return kn(i,u,a,e)})},kn=function(n,t,r,e){return ne(nn(e),function(e){return(Nn(e)?kn:wn)(n+1,t,r,e)})},An=tinymce.util.Tools.resolve("tinymce.Env"),xn=function(e,n){var t,r,o,i,u=e.dom,a=e.schema.getBlockElements(),s=u.createFragment();if(e.settings.forced_root_block&&(o=e.settings.forced_root_block),o&&((r=u.create(o)).tagName===e.settings.forced_root_block&&u.setAttribs(r,e.settings.forced_root_block_attrs),D(n.firstChild,a)||s.appendChild(r)),n)for(;t=n.firstChild;){var c=t.nodeName;i||"SPAN"===c&&"bookmark"===t.getAttribute("data-mce-type")||(i=!0),D(t,a)?(s.appendChild(t),r=null):o?(r||(r=u.create(o),s.appendChild(r)),r.appendChild(t)):s.appendChild(t)}return e.settings.forced_root_block?i||An.ie&&!(10<An.ie)||r.appendChild(u.create("br",{"data-mce-bogus":"1"})):s.appendChild(u.create("br")),s},Rn=function(i,e){return Q(e,function(e){var n,t,r,o=(n=e.content,r=(t||u.document).createDocumentFragment(),Y(n,function(e){r.appendChild(e.dom())}),he.fromDom(r));return he.fromDom(xn(i,o.dom()))})},In=function(e,n){return Ln(n),(t=e.contentDocument,r=n,o=J(r,function(e,n){return n.depth>e.length?yn(t,e,n):hn(t,e,n)},[]),re(o).map(function(e){return e.list})).toArray();var t,r,o},_n=function(e){var n,t,r=Q(pe.getSelectedListItems(e),he.fromDom);return ye([Z(r,B(Sn)),Z((n=r,t=te.call(n,0),t.reverse(),t),B(Sn))],function(e,n){return{start:e,end:n}})},Bn=function(a,e,s){var n,t,r,o=(n=e,t=_n(a),r=En(!1),Q(n,function(e){return{sourceList:e,entries:kn(0,t,r,e)}}));Y(o,function(e){var n,t,r,o,i,u;n=e.entries,t=s,Y(G(n,On),function(e){return function(e,n){switch(e){case"Indent":n.depth++;break;case"Outdent":n.depth--;break;case"Flatten":n.depth=0}}(t,e)}),r=e.sourceList,i=a,u=e.entries,o=ne(function(e,n){if(0===e.length)return[];for(var t=n(e[0]),r=[],o=[],i=0,u=e.length;i<u;i++){var a=e[i],s=n(a);s!==t&&(r.push(o),o=[]),t=s,o.push(a)}return 0!==o.length&&r.push(o),r}(u,Cn),function(e){return re(e).map(Cn).getOr(!1)?In(i,e):Rn(i,e)}),Y(o,function(e){un(r,e)}),cn(e.sourceList)})},Pn=m.DOM,Mn=function(e,n,t){var r,o,i,u,a,s;for(i=Pn.select('span[data-mce-type="bookmark"]',n),a=xn(e,t),(r=Pn.createRng()).setStartAfter(t),r.setEndAfter(n),u=(o=r.extractContents()).firstChild;u;u=u.firstChild)if("LI"===u.nodeName&&e.dom.isEmpty(u)){Pn.remove(u);break}e.dom.isEmpty(o)||Pn.insertAfter(o,n),Pn.insertAfter(a,n),E(e.dom,t.parentNode)&&(s=t.parentNode,v.each(i,function(e){s.parentNode.insertBefore(e,t.parentNode)}),Pn.remove(s)),Pn.remove(t),E(e.dom,n)&&Pn.remove(n)},Un=function(e){Ze(e,"DT")&&pn(e,"DD")},Fn=function(r,e,n){Y(n,"Indent"===e?Un:function(e){return n=r,void(Ze(t=e,"DD")?pn(t,"DT"):Ze(t,"DT")&&en(t).each(function(e){return Mn(n,e.dom(),t.dom())}));var n,t})},jn=function(e,n){var t=Q(pe.getSelectedListRoots(e),he.fromDom),r=Q(pe.getSelectedDlItems(e),he.fromDom),o=!1;if(t.length||r.length){var i=e.selection.getBookmark();Bn(e,t,n),Fn(e,n,r),e.selection.moveToBookmark(i),e.selection.setRng(A(e.selection.getRng())),e.nodeChanged(),o=!0}return o},Hn=function(e){return jn(e,"Indent")},$n=function(e){return jn(e,"Outdent")},qn=function(e){return jn(e,"Flatten")},Wn=function(t,e){v.each(e,function(e,n){t.setAttribute(n,e)})},zn=function(e,n,t){var r,o,i,u,a,s,c;r=e,o=n,u=(i=t)["list-style-type"]?i["list-style-type"]:null,r.setStyle(o,"list-style-type",u),a=e,Wn(s=n,(c=t)["list-attributes"]),v.each(a.select("li",s),function(e){Wn(e,c["list-item-attributes"])})},Kn=function(e,n,t,r){var o,i;for(o=n[t?"startContainer":"endContainer"],i=n[t?"startOffset":"endOffset"],1===o.nodeType&&(o=o.childNodes[Math.min(i,o.childNodes.length-1)]||o),!t&&b(o.nextSibling)&&(o=o.nextSibling);o.parentNode!==r;){if(T(e,o))return o;if(/^(TD|TH)$/.test(o.parentNode.nodeName))return o;o=o.parentNode}return o},Vn=function(f,d,l){void 0===l&&(l={});var e,n=f.selection.getRng(!0),m="LI",t=pe.getClosestListRootElm(f,f.selection.getStart(!0)),g=f.dom;"false"!==g.getContentEditable(f.selection.getNode())&&("DL"===(d=d.toUpperCase())&&(m="DT"),e=R(n),v.each(function(t,e,r){for(var o,i=[],u=t.dom,n=Kn(t,e,!0,r),a=Kn(t,e,!1,r),s=[],c=n;c&&(s.push(c),c!==a);c=c.nextSibling);return v.each(s,function(e){if(T(t,e))return i.push(e),void(o=null);if(u.isBlock(e)||b(e))return b(e)&&u.remove(e),void(o=null);var n=e.nextSibling;p.isBookmarkNode(e)&&(T(t,n)||!n&&e.parentNode===r)?o=null:(o||(o=u.create("p"),e.parentNode.insertBefore(o,e),i.push(o)),o.appendChild(e))}),i}(f,n,t),function(e){var n,t,r,o,i,u,a,s,c;(t=e.previousSibling)&&y(t)&&t.nodeName===d&&(r=t,o=l,i=g.getStyle(r,"list-style-type"),u=o?o["list-style-type"]:"",i===(u=null===u?"":u))?(n=t,e=g.rename(e,m),t.appendChild(e)):(n=g.create(d),e.parentNode.insertBefore(n,e),n.appendChild(e),e=g.rename(e,m)),a=g,s=e,c=["margin","margin-right","margin-bottom","margin-left","margin-top","padding","padding-right","padding-bottom","padding-left","padding-top"],v.each(c,function(e){var n;return a.setStyle(s,((n={})[e]="",n))}),zn(g,n,l),Qn(f.dom,n)}),f.selection.setRng(I(e)))},Xn=function(e,n,t){return s=t,(a=n)&&s&&y(a)&&a.nodeName===s.nodeName&&(i=n,u=t,(o=e).getStyle(i,"list-style-type",!0)===o.getStyle(u,"list-style-type",!0))&&(r=t,n.className===r.className);var r,o,i,u,a,s},Qn=function(e,n){var t,r;if(t=n.nextSibling,Xn(e,n,t)){for(;r=t.firstChild;)n.appendChild(r);e.remove(t)}if(t=n.previousSibling,Xn(e,n,t)){for(;r=t.lastChild;)n.insertBefore(r,n.firstChild);e.remove(t)}},Yn=function(n,e,t,r,o){if(e.nodeName!==r||Gn(o)){var i=R(n.selection.getRng(!0));v.each([e].concat(t),function(e){!function(e,n,t,r){if(n.nodeName!==t){var o=e.rename(n,t);zn(e,o,r)}else zn(e,n,r)}(n.dom,e,r,o)}),n.selection.setRng(I(i))}else qn(n)},Gn=function(e){return"list-style-type"in e},Jn={toggleList:function(e,n,t){var r=pe.getParentList(e),o=pe.getSelectedSubLists(e);t=t||{},r&&0<o.length?Yn(e,r,o,n,t):function(e,n,t,r){if(n!==e.getBody())if(n)if(n.nodeName!==t||Gn(r)){var o=R(e.selection.getRng(!0));zn(e.dom,n,r),Qn(e.dom,e.dom.rename(n,t)),e.selection.setRng(I(o))}else qn(e);else Vn(e,t,r)}(e,r,n,t)},mergeWithAdjacentLists:Qn},Zn=m.DOM,et=function(e,n){var t,r=n.parentNode;"LI"===r.nodeName&&r.firstChild===n&&((t=r.previousSibling)&&"LI"===t.nodeName?(t.appendChild(n),E(e,r)&&Zn.remove(r)):Zn.setStyle(r,"listStyleType","none")),y(r)&&(t=r.previousSibling)&&"LI"===t.nodeName&&t.appendChild(n)},nt=function(n,e){v.each(v.grep(n.select("ol,ul",e)),function(e){et(n,e)})},tt=function(e,n,t,r){var o,i,u=n.startContainer,a=n.startOffset;if(3===u.nodeType&&(t?a<u.data.length:0<a))return u;for(o=e.schema.getNonEmptyElements(),1===u.nodeType&&(u=f.getNode(u,a)),i=new d(u,r),t&&L(e.dom,u)&&i.next();u=i[t?"next":"prev2"]();){if("LI"===u.nodeName&&!u.hasChildNodes())return u;if(o[u.nodeName])return u;if(3===u.nodeType&&0<u.data.length)return u}},rt=function(e,n){var t=n.childNodes;return 1===t.length&&!y(t[0])&&e.isBlock(t[0])},ot=function(e,n,t){var r,o,i,u;if(o=rt(e,t)?t.firstChild:t,rt(i=e,u=n)&&i.remove(u.firstChild,!0),!E(e,n,!0))for(;r=n.firstChild;)o.appendChild(r)},it=function(n,e,t){var r,o,i=e.parentNode;if(w(n,e)&&w(n,t)){y(t.lastChild)&&(o=t.lastChild),i===t.lastChild&&b(i.previousSibling)&&n.remove(i.previousSibling),(r=t.lastChild)&&b(r)&&e.hasChildNodes()&&n.remove(r),E(n,t,!0)&&n.$(t).empty(),ot(n,e,t),o&&t.appendChild(o);var u=Je(he.fromDom(t),he.fromDom(e))?n.getParents(e,y,t):[];n.remove(e),Y(u,function(e){E(n,e)&&e!==n.getRoot()&&n.remove(e)})}},ut=function(e,n,t,r){var o,i,u,a=e.dom;if(a.isEmpty(r))i=t,u=r,(o=e).dom.$(u).empty(),it(o.dom,i,u),o.selection.setCursorLocation(u);else{var s=R(n);it(a,t,r),e.selection.setRng(I(s))}},at=function(e,n){var t,r,o,i=e.dom,u=e.selection,a=u.getStart(),s=pe.getClosestListRootElm(e,a),c=i.getParent(u.getStart(),"LI",s);if(c){if((t=c.parentNode)===e.getBody()&&E(i,t))return!0;if(r=A(u.getRng(!0)),(o=i.getParent(tt(e,r,n,s),"LI",s))&&o!==c)return n?ut(e,r,o,c):function(e,n,t,r){var o=R(n);it(e.dom,t,r);var i=I(o);e.selection.setRng(i)}(e,r,c,o),!0;if(!o&&!n)return qn(e),!0}return!1},st=function(e,n){return at(e,n)||function(o,i){var u=o.dom,e=o.selection.getStart(),a=pe.getClosestListRootElm(o,e),s=u.getParent(e,u.isBlock,a);if(s&&u.isEmpty(s)){var n=A(o.selection.getRng(!0)),c=u.getParent(tt(o,n,i,a),"LI",a);if(c)return o.undoManager.transact(function(){var e,n,t,r;n=s,t=a,r=(e=u).getParent(n.parentNode,e.isBlock,t),e.remove(n),r&&e.isEmpty(r)&&e.remove(r),Jn.mergeWithAdjacentLists(u,c.parentNode),o.selection.select(c,!0),o.selection.collapse(i)}),!0}return!1}(e,n)},ct=function(e,n){return e.selection.isCollapsed()?st(e,n):(r=(t=e).selection.getStart(),o=pe.getClosestListRootElm(t,r),!!(t.dom.getParent(r,"LI,DT,DD",o)||0<pe.getSelectedListItems(t).length)&&(t.undoManager.transact(function(){t.execCommand("Delete"),nt(t.dom,t.getBody())}),!0));var t,r,o},ft=function(n){n.on("keydown",function(e){e.keyCode===l.BACKSPACE?ct(n,!1)&&e.preventDefault():e.keyCode===l.DELETE&&ct(n,!0)&&e.preventDefault()})},dt=ct,lt=function(n){return{backspaceDelete:function(e){dt(n,e)}}},mt=function(n,t){return function(){var e=n.dom.getParent(n.selection.getStart(),"UL,OL,DL");return e&&e.nodeName===t}},gt=function(t){t.on("BeforeExecCommand",function(e){var n=e.command.toLowerCase();"indent"===n?Hn(t):"outdent"===n&&$n(t)}),t.addCommand("InsertUnorderedList",function(e,n){Jn.toggleList(t,"UL",n)}),t.addCommand("InsertOrderedList",function(e,n){Jn.toggleList(t,"OL",n)}),t.addCommand("InsertDefinitionList",function(e,n){Jn.toggleList(t,"DL",n)}),t.addCommand("RemoveList",function(){qn(t)}),t.addQueryStateHandler("InsertUnorderedList",mt(t,"UL")),t.addQueryStateHandler("InsertOrderedList",mt(t,"OL")),t.addQueryStateHandler("InsertDefinitionList",mt(t,"DL"))},pt=function(e){return e.getParam("lists_indent_on_tab",!0)},vt=function(e){var n;pt(e)&&(n=e).on("keydown",function(e){e.keyCode!==l.TAB||l.metaKeyPressed(e)||n.undoManager.transact(function(){(e.shiftKey?$n(n):Hn(n))&&e.preventDefault()})}),ft(e)},ht=function(n,i){return function(e){var o=e.control;n.on("NodeChange",function(e){var n=function(e,n){for(var t=0;t<e.length;t++)if(n(e[t]))return t;return-1}(e.parents,O),t=-1!==n?e.parents.slice(0,n):e.parents,r=v.grep(t,y);o.active(0<r.length&&r[0].nodeName===i)})}},yt=function(e){var n,t,r;t="advlist",r=(n=e).settings.plugins?n.settings.plugins:"",-1===v.inArray(r.split(/[ ,]/),t)&&(e.addButton("numlist",{active:!1,title:"Numbered list",cmd:"InsertOrderedList",onPostRender:ht(e,"OL")}),e.addButton("bullist",{active:!1,title:"Bullet list",cmd:"InsertUnorderedList",onPostRender:ht(e,"UL")})),e.addButton("indent",{icon:"indent",title:"Increase indent",cmd:"Indent"})};c.add("lists",function(e){return vt(e),yt(e),gt(e),lt(e)})}(window);
\ No newline at end of file

plugins/paste/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var paste = (function () {
+var paste = (function (domGlobals) {
'use strict';
var Cell = function (initial) {
@@ -24,8 +24,8 @@
var hasProPlugin = function (editor) {
if (/(^|[ ,])powerpaste([, ]|$)/.test(editor.settings.plugins) && global.get('powerpaste')) {
- if (typeof window.console !== 'undefined' && window.console.log) {
- window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.');
+ if (typeof domGlobals.window.console !== 'undefined' && domGlobals.window.console.log) {
+ domGlobals.window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.');
}
return true;
} else {
@@ -273,18 +273,18 @@
var ignoreElements = global$3.makeMap('script noscript style textarea video audio iframe object', ' ');
var blockElements = schema.getBlockElements();
function walk(node) {
- var name$$1 = node.name, currentNode = node;
- if (name$$1 === 'br') {
+ var name = node.name, currentNode = node;
+ if (name === 'br') {
text += '\n';
return;
}
- if (name$$1 === 'wbr') {
+ if (name === 'wbr') {
return;
}
- if (shortEndedElements[name$$1]) {
+ if (shortEndedElements[name]) {
text += ' ';
}
- if (ignoreElements[name$$1]) {
+ if (ignoreElements[name]) {
text += ' ';
return;
}
@@ -298,9 +298,9 @@
} while (node = node.next);
}
}
- if (blockElements[name$$1] && currentNode.next) {
+ if (blockElements[name] && currentNode.next) {
text += '\n';
- if (name$$1 === 'p') {
+ if (name === 'p') {
text += '\n';
}
}
@@ -335,7 +335,7 @@
};
}
var isMsEdge = function () {
- return navigator.userAgent.indexOf(' Edge/') !== -1;
+ return domGlobals.navigator.userAgent.indexOf(' Edge/') !== -1;
};
var Utils = {
filter: filter,
@@ -754,6 +754,356 @@
insertContent: insertContent
};
+ var constant = function (value) {
+ return function () {
+ return value;
+ };
+ };
+ function curry(fn) {
+ var initialArgs = [];
+ for (var _i = 1; _i < arguments.length; _i++) {
+ initialArgs[_i - 1] = arguments[_i];
+ }
+ return function () {
+ var restArgs = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ restArgs[_i] = arguments[_i];
+ }
+ var all = initialArgs.concat(restArgs);
+ return fn.apply(null, all);
+ };
+ }
+ var never = constant(false);
+ var always = constant(true);
+
+ var never$1 = never;
+ var always$1 = always;
+ var none = function () {
+ return NONE;
+ };
+ var NONE = function () {
+ var eq = function (o) {
+ return o.isNone();
+ };
+ var call = function (thunk) {
+ return thunk();
+ };
+ var id = function (n) {
+ return n;
+ };
+ var noop = 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,
+ getOr: id,
+ getOrThunk: call,
+ getOrDie: function (msg) {
+ throw new Error(msg || 'error: getOrDie called on none.');
+ },
+ getOrNull: nul,
+ getOrUndefined: undef,
+ or: id,
+ orThunk: call,
+ map: none,
+ ap: none,
+ each: noop,
+ bind: none,
+ flatten: none,
+ exists: never$1,
+ forall: always$1,
+ filter: none,
+ equals: eq,
+ equals_: eq,
+ toArray: function () {
+ return [];
+ },
+ toString: constant('none()')
+ };
+ if (Object.freeze)
+ Object.freeze(me);
+ return me;
+ }();
+ var some = function (a) {
+ var constant_a = function () {
+ return a;
+ };
+ var self = function () {
+ return me;
+ };
+ var map = function (f) {
+ return some(f(a));
+ };
+ var bind = function (f) {
+ return f(a);
+ };
+ var me = {
+ fold: function (n, s) {
+ return s(a);
+ },
+ is: function (v) {
+ return a === v;
+ },
+ isSome: always$1,
+ isNone: never$1,
+ getOr: constant_a,
+ getOrThunk: constant_a,
+ getOrDie: constant_a,
+ getOrNull: constant_a,
+ getOrUndefined: constant_a,
+ or: self,
+ orThunk: self,
+ map: map,
+ ap: function (optfab) {
+ return optfab.fold(none, function (fab) {
+ return some(fab(a));
+ });
+ },
+ each: function (f) {
+ f(a);
+ },
+ bind: bind,
+ flatten: constant_a,
+ exists: bind,
+ forall: bind,
+ filter: function (f) {
+ return f(a) ? me : NONE;
+ },
+ equals: function (o) {
+ return o.is(a);
+ },
+ equals_: function (o, elementEq) {
+ return o.fold(never$1, function (b) {
+ return elementEq(a, b);
+ });
+ },
+ toArray: function () {
+ return [a];
+ },
+ toString: function () {
+ return 'some(' + a + ')';
+ }
+ };
+ return me;
+ };
+ var from = function (value) {
+ return value === null || value === undefined ? NONE : some(value);
+ };
+ var Option = {
+ some: some,
+ none: none,
+ from: from
+ };
+
+ var typeOf = function (x) {
+ if (x === null)
+ return 'null';
+ var t = typeof x;
+ if (t === 'object' && Array.prototype.isPrototypeOf(x))
+ return 'array';
+ if (t === 'object' && String.prototype.isPrototypeOf(x))
+ return 'string';
+ return t;
+ };
+ var isType = function (type) {
+ return function (value) {
+ return typeOf(value) === type;
+ };
+ };
+ var isFunction = isType('function');
+
+ var map = function (xs, f) {
+ var len = xs.length;
+ var r = new Array(len);
+ for (var i = 0; i < len; i++) {
+ var x = xs[i];
+ r[i] = f(x, i, xs);
+ }
+ return r;
+ };
+ var each = function (xs, f) {
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ f(x, i, xs);
+ }
+ };
+ var filter$1 = function (xs, pred) {
+ var r = [];
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ if (pred(x, i, xs)) {
+ r.push(x);
+ }
+ }
+ return r;
+ };
+ var slice = Array.prototype.slice;
+ var from$1 = isFunction(Array.from) ? Array.from : function (x) {
+ return slice.call(x);
+ };
+
+ var nu = function (baseFn) {
+ var data = Option.none();
+ var callbacks = [];
+ var map = function (f) {
+ return nu(function (nCallback) {
+ get(function (data) {
+ nCallback(f(data));
+ });
+ });
+ };
+ var get = function (nCallback) {
+ if (isReady())
+ call(nCallback);
+ else
+ callbacks.push(nCallback);
+ };
+ var set = function (x) {
+ data = Option.some(x);
+ run(callbacks);
+ callbacks = [];
+ };
+ var isReady = function () {
+ return data.isSome();
+ };
+ var run = function (cbs) {
+ each(cbs, call);
+ };
+ var call = function (cb) {
+ data.each(function (x) {
+ domGlobals.setTimeout(function () {
+ cb(x);
+ }, 0);
+ });
+ };
+ baseFn(set);
+ return {
+ get: get,
+ map: map,
+ isReady: isReady
+ };
+ };
+ var pure = function (a) {
+ return nu(function (callback) {
+ callback(a);
+ });
+ };
+ var LazyValue = {
+ nu: nu,
+ pure: pure
+ };
+
+ var bounce = function (f) {
+ return function () {
+ var args = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ args[_i] = arguments[_i];
+ }
+ var me = this;
+ domGlobals.setTimeout(function () {
+ f.apply(me, args);
+ }, 0);
+ };
+ };
+
+ var nu$1 = function (baseFn) {
+ var get = function (callback) {
+ baseFn(bounce(callback));
+ };
+ var map = function (fab) {
+ return nu$1(function (callback) {
+ get(function (a) {
+ var value = fab(a);
+ callback(value);
+ });
+ });
+ };
+ var bind = function (aFutureB) {
+ return nu$1(function (callback) {
+ get(function (a) {
+ aFutureB(a).get(callback);
+ });
+ });
+ };
+ var anonBind = function (futureB) {
+ return nu$1(function (callback) {
+ get(function (a) {
+ futureB.get(callback);
+ });
+ });
+ };
+ var toLazy = function () {
+ return LazyValue.nu(get);
+ };
+ var toCached = function () {
+ var cache = null;
+ return nu$1(function (callback) {
+ if (cache === null) {
+ cache = toLazy();
+ }
+ cache.get(callback);
+ });
+ };
+ return {
+ map: map,
+ bind: bind,
+ anonBind: anonBind,
+ toLazy: toLazy,
+ toCached: toCached,
+ get: get
+ };
+ };
+ var pure$1 = function (a) {
+ return nu$1(function (callback) {
+ callback(a);
+ });
+ };
+ var Future = {
+ nu: nu$1,
+ pure: pure$1
+ };
+
+ var par = function (asyncValues, nu) {
+ return nu(function (callback) {
+ var r = [];
+ var count = 0;
+ var cb = function (i) {
+ return function (value) {
+ r[i] = value;
+ count++;
+ if (count >= asyncValues.length) {
+ callback(r);
+ }
+ };
+ };
+ if (asyncValues.length === 0) {
+ callback([]);
+ } else {
+ each(asyncValues, function (asyncValue, i) {
+ asyncValue.get(cb(i));
+ });
+ }
+ });
+ };
+
+ var par$1 = function (futures) {
+ return par(futures, Future.nu);
+ };
+ var mapM = function (array, fn) {
+ var futures = map(array, fn);
+ return par$1(futures);
+ };
+
var pasteHtml$1 = function (editor, html, internalFlag) {
var internal = internalFlag ? internalFlag : InternalHtml.isMarked(html);
var args = ProcessFilters.process(editor, InternalHtml.unmark(html), internal);
@@ -817,17 +1167,12 @@
return m ? editor.dom.encode(m[1]) : null;
};
var uniqueId = Utils.createIdGenerator('mceclip');
- var pasteImage = function (editor, rng, reader, blob) {
- if (rng) {
- editor.selection.setRng(rng);
- rng = null;
- }
- var dataUri = reader.result;
- var base64 = getBase64FromUri(dataUri);
+ var pasteImage = function (editor, imageItem) {
+ var base64 = getBase64FromUri(imageItem.uri);
var id = uniqueId();
- var name$$1 = editor.settings.images_reuse_filename && blob.name ? extractFilename(editor, blob.name) : id;
- var img = new Image();
- img.src = dataUri;
+ var name = editor.settings.images_reuse_filename && imageItem.blob.name ? extractFilename(editor, imageItem.blob.name) : id;
+ var img = new domGlobals.Image();
+ img.src = imageItem.uri;
if (isValidDataUriImage(editor.settings, img)) {
var blobCache = editor.editorUpload.blobCache;
var blobInfo = void 0, existingBlobInfo = void 0;
@@ -835,45 +1180,66 @@
return cachedBlobInfo.base64() === base64;
});
if (!existingBlobInfo) {
- blobInfo = blobCache.create(id, blob, base64, name$$1);
+ blobInfo = blobCache.create(id, imageItem.blob, base64, name);
blobCache.add(blobInfo);
} else {
blobInfo = existingBlobInfo;
}
pasteHtml$1(editor, '<img src="' + blobInfo.blobUri() + '">', false);
} else {
- pasteHtml$1(editor, '<img src="' + dataUri + '">', false);
+ pasteHtml$1(editor, '<img src="' + imageItem.uri + '">', false);
}
};
- var isClipboardEvent = function (event$$1) {
- return event$$1.type === 'paste';
+ var isClipboardEvent = function (event) {
+ return event.type === 'paste';
};
- var pasteImageData = function (editor, e, rng) {
- var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;
- function processItems(items) {
- var i, item, reader, hadImage = false;
- if (items) {
- for (i = 0; i < items.length; i++) {
- item = items[i];
- if (/^image\/(jpeg|png|gif|bmp)$/.test(item.type)) {
+ var readBlobsAsDataUris = function (items) {
+ return mapM(items, function (item) {
+ return Future.nu(function (resolve) {
var blob = item.getAsFile ? item.getAsFile() : item;
- reader = new window.FileReader();
- reader.onload = pasteImage.bind(null, editor, rng, reader, blob);
+ var reader = new window.FileReader();
+ reader.onload = function () {
+ resolve({
+ blob: blob,
+ uri: reader.result
+ });
+ };
reader.readAsDataURL(blob);
+ });
+ });
+ };
+ var getImagesFromDataTransfer = function (dataTransfer) {
+ var items = dataTransfer.items ? map(from$1(dataTransfer.items), function (item) {
+ return item.getAsFile();
+ }) : [];
+ var files = dataTransfer.files ? from$1(dataTransfer.files) : [];
+ var images = filter$1(items.length > 0 ? items : files, function (file) {
+ return /^image\/(jpeg|png|gif|bmp)$/.test(file.type);
+ });
+ return images;
+ };
+ var pasteImageData = function (editor, e, rng) {
+ var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;
+ if (editor.settings.paste_data_images && dataTransfer) {
+ var images = getImagesFromDataTransfer(dataTransfer);
+ if (images.length > 0) {
e.preventDefault();
- hadImage = true;
- }
- }
+ readBlobsAsDataUris(images).get(function (blobResults) {
+ if (rng) {
+ editor.selection.setRng(rng);
}
- return hadImage;
+ each(blobResults, function (result) {
+ pasteImage(editor, result);
+ });
+ });
+ return true;
}
- if (editor.settings.paste_data_images && dataTransfer) {
- return processItems(dataTransfer.items) || processItems(dataTransfer.files);
}
+ return false;
};
var isBrokenAndroidClipboardEvent = function (e) {
var clipboardData = e.clipboardData;
- return navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
+ return domGlobals.navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
};
var isKeyboardPasteEvent = function (e) {
return global$4.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45;
@@ -889,7 +1255,7 @@
}
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;
- if (keyboardPastePlainTextState && global$1.webkit && navigator.userAgent.indexOf('Version/') !== -1) {
+ if (keyboardPastePlainTextState && global$1.webkit && domGlobals.navigator.userAgent.indexOf('Version/') !== -1) {
return;
}
e.stopImmediatePropagation();
@@ -989,7 +1355,7 @@
var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) {
registerEventHandlers(editor, pasteBin, pasteFormat);
var src;
- editor.parser.addNodeFilter('img', function (nodes, name$$1, args) {
+ editor.parser.addNodeFilter('img', function (nodes, name, args) {
var isPasteInsert = function (args) {
return args.data && args.data.paste === true;
};
@@ -1022,7 +1388,7 @@
};
var getPasteBinParent = function (editor) {
- return global$1.ie && editor.inline ? document.body : editor.getBody();
+ return global$1.ie && editor.inline ? domGlobals.document.body : editor.getBody();
};
var isExternalPasteBin = function (editor) {
return getPasteBinParent(editor) !== editor.getBody();
@@ -1221,9 +1587,15 @@
text: editor.selection.getContent({ format: 'text' })
};
};
+ var isTableSelection = function (editor) {
+ return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
+ };
+ var hasSelectedContent = function (editor) {
+ return !editor.selection.isCollapsed() || isTableSelection(editor);
+ };
var cut = function (editor) {
return function (evt) {
- if (editor.selection.isCollapsed() === false) {
+ if (hasSelectedContent(editor)) {
setClipboardData(evt, getData(editor), fallback(editor), function () {
setTimeout(function () {
editor.execCommand('Delete');
@@ -1234,7 +1606,7 @@
};
var copy = function (editor) {
return function (evt) {
- if (editor.selection.isCollapsed() === false) {
+ if (hasSelectedContent(editor)) {
setClipboardData(evt, getData(editor), fallback(editor), noop);
}
};
@@ -1436,27 +1808,6 @@
};
var Quirks = { setup: setup$2 };
- var curry = function (f) {
- var x = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- x[_i - 1] = arguments[_i];
- }
- var args = new Array(arguments.length - 1);
- for (var i = 1; i < arguments.length; i++)
- args[i - 1] = arguments[i];
- return function () {
- var x = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
- }
- var newArgs = new Array(arguments.length);
- for (var j = 0; j < newArgs.length; j++)
- newArgs[j] = arguments[j];
- var all = args.concat(newArgs);
- return f.apply(null, all);
- };
- };
-
var stateChange = function (editor, clipboard, e) {
var ctrl = e.control;
ctrl.active(clipboard.pasteFormat.get() === 'text');
@@ -1503,5 +1854,5 @@
return Plugin;
-}());
+}(window));
})();

plugins/paste/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var u=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return u(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),o=function(e){return!(!/(^|[ ,])powerpaste([, ]|$)/.test(e.settings.plugins)||!t.get("powerpaste")||("undefined"!=typeof window.console&&window.console.log&&window.console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option."),0))},s=function(e,t){return{clipboard:e,quirks:t}},f=function(e,t,n,r){return e.fire("PastePreProcess",{content:t,internal:n,wordContent:r})},d=function(e,t,n,r){return e.fire("PastePostProcess",{node:t,internal:n,wordContent:r})},l=function(e,t){return e.fire("PastePlainTextToggle",{state:t})},n=function(e,t){return e.fire("paste",{ieFake:t})},m={shouldPlainTextInform:function(e){return e.getParam("paste_plaintext_inform",!0)},shouldBlockDrop:function(e){return e.getParam("paste_block_drop",!1)},shouldPasteDataImages:function(e){return e.getParam("paste_data_images",!1)},shouldFilterDrop:function(e){return e.getParam("paste_filter_drop",!0)},getPreProcess:function(e){return e.getParam("paste_preprocess")},getPostProcess:function(e){return e.getParam("paste_postprocess")},getWebkitStyles:function(e){return e.getParam("paste_webkit_styles")},shouldRemoveWebKitStyles:function(e){return e.getParam("paste_remove_styles_if_webkit",!0)},shouldMergeFormats:function(e){return e.getParam("paste_merge_formats",!0)},isSmartPasteEnabled:function(e){return e.getParam("smart_paste",!0)},isPasteAsTextEnabled:function(e){return e.getParam("paste_as_text",!1)},getRetainStyleProps:function(e){return e.getParam("paste_retain_style_properties")},getWordValidElements:function(e){return e.getParam("paste_word_valid_elements","-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody")},shouldConvertWordFakeLists:function(e){return e.getParam("paste_convert_word_fake_lists",!0)},shouldUseDefaultFilters:function(e){return e.getParam("paste_enable_default_filters",!0)}},r=function(e,t,n){var r,a,i;"text"===t.pasteFormat.get()?(t.pasteFormat.set("html"),l(e,!1)):(t.pasteFormat.set("text"),l(e,!0),i=e,!1===n.get()&&m.shouldPlainTextInform(i)&&(a="Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.",(r=e).notificationManager.open({text:r.translate(a),type:"info"}),n.set(!0))),e.focus()},c=function(e,n,t){e.addCommand("mceTogglePlainTextPaste",function(){r(e,n,t)}),e.addCommand("mceInsertClipboardContent",function(e,t){t.content&&n.pasteHtml(t.content,t.internal),t.text&&n.pasteText(t.text)})},v=tinymce.util.Tools.resolve("tinymce.Env"),h=tinymce.util.Tools.resolve("tinymce.util.Delay"),b=tinymce.util.Tools.resolve("tinymce.util.Tools"),a=tinymce.util.Tools.resolve("tinymce.util.VK"),e="x-tinymce/html",i="\x3c!-- "+e+" --\x3e",p=function(e){return i+e},g=function(e){return e.replace(i,"")},y=function(e){return-1!==e.indexOf(i)},x=function(){return e},P=tinymce.util.Tools.resolve("tinymce.html.Entities"),w=function(e){return e.replace(/\r?\n/g,"<br>")},_=function(e,t,n){var r=e.split(/\n\n/),a=function(e,t){var n,r=[],a="<"+e;if("object"==typeof t){for(n in t)t.hasOwnProperty(n)&&r.push(n+'="'+P.encodeAllRaw(t[n])+'"');r.length&&(a+=" "+r.join(" "))}return a+">"}(t,n),i="</"+t+">",o=b.map(r,function(e){return e.split(/\n/).join("<br />")});return 1===o.length?o[0]:b.map(o,function(e){return a+e+i}).join("")},D=function(e){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(e)},T=function(e,t,n){return t?_(e,t,n):w(e)},C=tinymce.util.Tools.resolve("tinymce.html.DomParser"),k=tinymce.util.Tools.resolve("tinymce.html.Node"),R=tinymce.util.Tools.resolve("tinymce.html.Schema"),F=tinymce.util.Tools.resolve("tinymce.html.Serializer");function E(t,e){return b.each(e,function(e){t=e.constructor===RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}var S={filter:E,innerText:function(t){var n=R(),r=C({},n),a="",i=n.getShortEndedElements(),o=b.makeMap("script noscript style textarea video audio iframe object"," "),s=n.getBlockElements();return t=E(t,[/<!\[[^\]]+\]>/g]),function e(t){var n=t.name,r=t;if("br"!==n){if("wbr"!==n)if(i[n]&&(a+=" "),o[n])a+=" ";else{if(3===t.type&&(a+=t.value),!t.shortEnded&&(t=t.firstChild))for(;e(t),t=t.next;);s[n]&&r.next&&(a+="\n","p"===n&&(a+="\n"))}}else a+="\n"}(r.parse(t)),a},trimHtml:function(e){return e=E(e,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,function(e,t,n){return t||n?"\xa0":" "}],/<br class="Apple-interchange-newline">/g,/<br>$/i])},createIdGenerator:function(e){var t=0;return function(){return e+t++}},isMsEdge:function(){return-1!==navigator.userAgent.indexOf(" Edge/")}};function I(t){var n,e;return e=[/^[IVXLMCD]{1,2}\.[ \u00a0]/,/^[ivxlmcd]{1,2}\.[ \u00a0]/,/^[a-z]{1,2}[\.\)][ \u00a0]/,/^[A-Z]{1,2}[\.\)][ \u00a0]/,/^[0-9]+\.[ \u00a0]/,/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/],t=t.replace(/^[\u00a0 ]+/,""),b.each(e,function(e){if(e.test(t))return!(n=!0)}),n}function M(e){var i,o,s=1;function n(e){var t="";if(3===e.type)return e.value;if(e=e.firstChild)for(;t+=n(e),e=e.next;);return t}function l(e,t){if(3===e.type&&t.test(e.value))return e.value=e.value.replace(t,""),!1;if(e=e.firstChild)do{if(!l(e,t))return!1}while(e=e.next);return!0}function t(t,n,r){var a=t._listLevel||s;a!==s&&(a<s?i&&(i=i.parent.parent):(o=i,i=null)),i&&i.name===n?i.append(t):(o=o||i,i=new k(n,1),1<r&&i.attr("start",""+r),t.wrap(i)),t.name="li",s<a&&o&&o.lastChild.append(i),s=a,function e(t){if(t._listIgnore)t.remove();else if(t=t.firstChild)for(;e(t),t=t.next;);}(t),l(t,/^\u00a0+/),l(t,/^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/),l(t,/^\u00a0+/)}for(var r=[],a=e.firstChild;null!=a;)if(r.push(a),null!==(a=a.walk()))for(;void 0!==a&&a.parent!==e;)a=a.walk();for(var u=0;u<r.length;u++)if("p"===(e=r[u]).name&&e.firstChild){var c=n(e);if(/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(c)){t(e,"ul");continue}if(I(c)){var f=/([0-9]+)\./.exec(c),d=1;f&&(d=parseInt(f[1],10)),t(e,"ol",d);continue}if(e._listLevel){t(e,"ul",1);continue}i=null}else o=i,i=null}function A(n,r,a,i){var o,s={},e=n.dom.parseStyle(i);return b.each(e,function(e,t){switch(t){case"mso-list":(o=/\w+ \w+([0-9]+)/i.exec(i))&&(a._listLevel=parseInt(o[1],10)),/Ignore/i.test(e)&&a.firstChild&&(a._listIgnore=!0,a.firstChild._listIgnore=!0);break;case"horiz-align":t="text-align";break;case"vert-align":t="vertical-align";break;case"font-color":case"mso-foreground":t="color";break;case"mso-background":case"mso-highlight":t="background";break;case"font-weight":case"font-style":return void("normal"!==e&&(s[t]=e));case"mso-element":if(/^(comment|comment-list)$/i.test(e))return void a.remove()}0!==t.indexOf("mso-comment")?0!==t.indexOf("mso-")&&("all"===m.getRetainStyleProps(n)||r&&r[t])&&(s[t]=e):a.remove()}),/(bold)/i.test(s["font-weight"])&&(delete s["font-weight"],a.wrap(new k("b",1))),/(italic)/i.test(s["font-style"])&&(delete s["font-style"],a.wrap(new k("i",1))),(s=n.dom.serializeStyle(s,a.name))||null}var O={preProcess:function(e,t){return m.shouldUseDefaultFilters(e)?function(r,e){var t,a;(t=m.getRetainStyleProps(r))&&(a=b.makeMap(t.split(/[, ]/))),e=S.filter(e,[/<br class="?Apple-interchange-newline"?>/gi,/<b[^>]+id="?docs-internal-[^>]*>/gi,/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/&nbsp;/gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(e,t){return 0<t.length?t.replace(/./," ").slice(Math.floor(t.length/2)).split("").join("\xa0"):""}]]);var n=m.getWordValidElements(r),i=R({valid_elements:n,valid_children:"-li[p]"});b.each(i.elements,function(e){e.attributes["class"]||(e.attributes["class"]={},e.attributesOrder.push("class")),e.attributes.style||(e.attributes.style={},e.attributesOrder.push("style"))});var o=C({},i);o.addAttributeFilter("style",function(e){for(var t,n=e.length;n--;)(t=e[n]).attr("style",A(r,a,t,t.attr("style"))),"span"===t.name&&t.parent&&!t.attributes.length&&t.unwrap()}),o.addAttributeFilter("class",function(e){for(var t,n,r=e.length;r--;)n=(t=e[r]).attr("class"),/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(n)&&t.remove(),t.attr("class",null)}),o.addNodeFilter("del",function(e){for(var t=e.length;t--;)e[t].remove()}),o.addNodeFilter("a",function(e){for(var t,n,r,a=e.length;a--;)if(n=(t=e[a]).attr("href"),r=t.attr("name"),n&&-1!==n.indexOf("#_msocom_"))t.remove();else if(n&&0===n.indexOf("file://")&&(n=n.split("#")[1])&&(n="#"+n),n||r){if(r&&!/^_?(?:toc|edn|ftn)/i.test(r)){t.unwrap();continue}t.attr({href:n,name:r})}else t.unwrap()});var s=o.parse(e);return m.shouldConvertWordFakeLists(r)&&M(s),e=F({validate:r.settings.validate},i).serialize(s)}(e,t):t},isWordContent:function(e){return/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(e)||/class="OutlineElement/.test(e)||/id="?docs\-internal\-guid\-/.test(e)}},H=function(e,t){return{content:e,cancelled:t}},B=function(e,t,n,r){var a,i,o,s,l,u,c=f(e,t,n,r);return e.hasEventListeners("PastePostProcess")&&!c.isDefaultPrevented()?(a=e,i=c.content,o=n,s=r,l=a.dom.create("div",{style:"display:none"},i),u=d(a,l,o,s),H(u.node.innerHTML,u.isDefaultPrevented())):H(c.content,c.isDefaultPrevented())},L=function(e,t,n){var r=O.isWordContent(t),a=r?O.preProcess(e,t):t;return B(e,a,n,r)},$=function(e,t){var n,r;return e.insertContent((n=t,r=e.dom.create("body",{},n),b.each(r.querySelectorAll("meta"),function(e){return e.parentNode.removeChild(e)}),r.innerHTML),{merge:m.shouldMergeFormats(e),paste:!0}),!0},j=function(e){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(e)},W=function(e){return j(e)&&/.(gif|jpe?g|png)$/.test(e)},N=function(e,t,n){return!(!1!==e.selection.isCollapsed()||!j(t)||(a=t,i=n,(r=e).undoManager.extra(function(){i(r,a)},function(){r.execCommand("mceInsertLink",!1,a)}),0));var r,a,i},V=function(e,t,n){return!!W(t)&&(a=t,i=n,(r=e).undoManager.extra(function(){i(r,a)},function(){r.insertContent('<img src="'+a+'">')}),!0);var r,a,i},z=function(e,t){var n,r;!1===m.isSmartPasteEnabled(e)?$(e,t):(n=e,r=t,b.each([N,V,$],function(e){return!0!==e(n,r,$)}))},K=function(e,t,n){var r=n||y(t),a=L(e,g(t),r);!1===a.cancelled&&z(e,a.content)},U=function(e,t){t=e.dom.encode(t).replace(/\r\n/g,"\n"),t=T(t,e.settings.forced_root_block,e.settings.forced_root_block_attrs),K(e,t,!1)},q=function(e){var t={};if(e){if(e.getData){var n=e.getData("Text");n&&0<n.length&&-1===n.indexOf("data:text/mce-internal,")&&(t["text/plain"]=n)}if(e.types)for(var r=0;r<e.types.length;r++){var a=e.types[r];try{t[a]=e.getData(a)}catch(i){t[a]=""}}}return t},G=function(e,t){return t in e&&0<e[t].length},X=function(e){return G(e,"text/html")||G(e,"text/plain")},Y=S.createIdGenerator("mceclip"),Z=function(e,t,n,r){t&&(e.selection.setRng(t),t=null);var a,i,o,s,l,u,c,f=n.result,d=-1!==(i=(a=f).indexOf(","))?a.substr(i+1):null,m=Y(),p=e.settings.images_reuse_filename&&r.name?(o=e,s=r.name,(l=s.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i))?o.dom.encode(l[1]):null):m,g=new Image;if(g.src=f,u=e.settings,c=g,!u.images_dataimg_filter||u.images_dataimg_filter(c)){var v,h=e.editorUpload.blobCache,b=void 0;(v=h.findFirst(function(e){return e.base64()===d}))?b=v:(b=h.create(m,r,d,p),h.add(b)),K(e,'<img src="'+b.blobUri()+'">',!1)}else K(e,'<img src="'+f+'">',!1)},J=function(o,s,l){var e="paste"===s.type?s.clipboardData:s.dataTransfer;function t(e){var t,n,r,a=!1;if(e)for(t=0;t<e.length;t++)if(n=e[t],/^image\/(jpeg|png|gif|bmp)$/.test(n.type)){var i=n.getAsFile?n.getAsFile():n;(r=new window.FileReader).onload=Z.bind(null,o,l,r,i),r.readAsDataURL(i),s.preventDefault(),a=!0}return a}if(o.settings.paste_data_images&&e)return t(e.items)||t(e.files)},Q=function(e){return a.metaKeyPressed(e)&&86===e.keyCode||e.shiftKey&&45===e.keyCode},ee=function(c,f,d){var m,p=0;function g(e,t,n,r){var a,i;G(e,"text/html")?a=e["text/html"]:(a=f.getHtml(),r=r||y(a),f.isDefaultContent(a)&&(n=!0)),a=S.trimHtml(a),f.remove(),i=!1===r&&D(a),a.length&&!i||(n=!0),n&&(a=G(e,"text/plain")&&i?e["text/plain"]:S.innerText(a)),f.isDefaultContent(a)?t||c.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."):n?U(c,a):K(c,a,r)}c.on("keydown",function(e){function t(e){Q(e)&&!e.isDefaultPrevented()&&f.remove()}if(Q(e)&&!e.isDefaultPrevented()){if((m=e.shiftKey&&86===e.keyCode)&&v.webkit&&-1!==navigator.userAgent.indexOf("Version/"))return;if(e.stopImmediatePropagation(),p=(new Date).getTime(),v.ie&&m)return e.preventDefault(),void n(c,!0);f.remove(),f.create(),c.once("keyup",t),c.once("paste",function(){c.off("keyup",t)})}}),c.on("paste",function(e){var t,n,r,a=(new Date).getTime(),i=(t=c,n=q(e.clipboardData||t.getDoc().dataTransfer),S.isMsEdge()?b.extend(n,{"text/html":""}):n),o=(new Date).getTime()-a,s=(new Date).getTime()-p-o<1e3,l="text"===d.get()||m,u=G(i,x());m=!1,e.isDefaultPrevented()||(r=e.clipboardData,-1!==navigator.userAgent.indexOf("Android")&&r&&r.items&&0===r.items.length)?f.remove():X(i)||!J(c,e,f.getLastRng()||c.selection.getRng())?(s||e.preventDefault(),!v.ie||s&&!e.ieFake||G(i,"text/html")||(f.create(),c.dom.bind(f.getEl(),"paste",function(e){e.stopPropagation()}),c.getDoc().execCommand("Paste",!1,null),i["text/html"]=f.getHtml()),G(i,"text/html")?(e.preventDefault(),u||(u=y(i["text/html"])),g(i,s,l,u)):h.setEditorTimeout(c,function(){g(i,s,l,u)},0)):f.remove()})},te=function(e){return v.ie&&e.inline?document.body:e.getBody()},ne=function(t,e,n){var r;te(r=t)!==r.getBody()&&t.dom.bind(e,"paste keyup",function(e){ie(t,n)||t.fire("paste")})},re=function(e){return e.dom.get("mcepastebin")},ae=function(e,t){return t===e},ie=function(e,t){var n,r=re(e);return(n=r)&&"mcepastebin"===n.id&&ae(t,r.innerHTML)},oe=function(o){var s=u(null),l="%MCEPASTEBIN%";return{create:function(){return t=s,n=l,a=(e=o).dom,i=e.getBody(),t.set(e.selection.getRng()),r=e.dom.add(te(e),"div",{id:"mcepastebin","class":"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},n),(v.ie||v.gecko)&&a.setStyle(r,"left","rtl"===a.getStyle(i,"direction",!0)?65535:-65535),a.bind(r,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),ne(e,r,n),r.focus(),void e.selection.select(r,!0);var e,t,n,r,a,i},remove:function(){return function(e,t){if(re(e)){for(var n=void 0,r=t.get();n=e.dom.get("mcepastebin");)e.dom.remove(n),e.dom.unbind(n);r&&e.selection.setRng(r)}t.set(null)}(o,s)},getEl:function(){return re(o)},getHtml:function(){return function(n){var t,e,r,a,i,o=function(e,t){e.appendChild(t),n.dom.remove(t,!0)};for(e=b.grep(te(n).childNodes,function(e){return"mcepastebin"===e.id}),t=e.shift(),b.each(e,function(e){o(t,e)}),r=(a=n.dom.select("div[id=mcepastebin]",t)).length-1;0<=r;r--)i=n.dom.create("div"),t.insertBefore(i,a[r]),o(i,a[r]);return t?t.innerHTML:""}(o)},getLastRng:function(){return s.get()},isDefault:function(){return ie(o,l)},isDefaultContent:function(e){return ae(l,e)}}},se=function(n,e){var t=oe(n);return n.on("preInit",function(){return ee(o=n,t,e),void o.parser.addNodeFilter("img",function(e,t,n){var r,a=function(e){e.attr("data-mce-object")||s===v.transparentSrc||e.remove()};if(!o.settings.paste_data_images&&(r=n).data&&!0===r.data.paste)for(var i=e.length;i--;)(s=e[i].attributes.map.src)&&(0===s.indexOf("webkit-fake-url")?a(e[i]):o.settings.allow_html_data_urls||0!==s.indexOf("data:")||a(e[i]))});var o,s}),{pasteFormat:e,pasteHtml:function(e,t){return K(n,e,t)},pasteText:function(e){return U(n,e)},pasteImageData:function(e,t){return J(n,e,t)},getDataTransferItems:q,hasHtmlOrText:X,hasContentType:G}},le=function(){},ue=function(e,t,n){if(r=e,!1!==v.iOS||r===undefined||"function"!=typeof r.setData||!0===S.isMsEdge())return!1;try{return e.clearData(),e.setData("text/html",t),e.setData("text/plain",n),e.setData(x(),t),!0}catch(a){return!1}var r},ce=function(e,t,n,r){ue(e.clipboardData,t.html,t.text)?(e.preventDefault(),r()):n(t.html,r)},fe=function(s){return function(e,t){var n=p(e),r=s.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),a=s.dom.create("div",{contenteditable:"true"},n);s.dom.setStyles(r,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),r.appendChild(a),s.dom.add(s.getBody(),r);var i=s.selection.getRng();a.focus();var o=s.dom.createRng();o.selectNodeContents(a),s.selection.setRng(o),setTimeout(function(){s.selection.setRng(i),r.parentNode.removeChild(r),t()},0)}},de=function(e){return{html:e.selection.getContent({contextual:!0}),text:e.selection.getContent({format:"text"})}},me=function(e){var t,n;e.on("cut",(t=e,function(e){!1===t.selection.isCollapsed()&&ce(e,de(t),fe(t),function(){setTimeout(function(){t.execCommand("Delete")},0)})})),e.on("copy",(n=e,function(e){!1===n.selection.isCollapsed()&&ce(e,de(n),fe(n),le)}))},pe=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),ge=function(e,t){return pe.getCaretRangeFromPoint(t.clientX,t.clientY,e.getDoc())},ve=function(e,t){e.focus(),e.selection.setRng(t)},he=function(o,s,l){m.shouldBlockDrop(o)&&o.on("dragend dragover draggesture dragdrop drop drag",function(e){e.preventDefault(),e.stopPropagation()}),m.shouldPasteDataImages(o)||o.on("drop",function(e){var t=e.dataTransfer;t&&t.files&&0<t.files.length&&e.preventDefault()}),o.on("drop",function(e){var t,n;if(n=ge(o,e),!e.isDefaultPrevented()&&!l.get()){t=s.getDataTransferItems(e.dataTransfer);var r,a=s.hasContentType(t,x());if((s.hasHtmlOrText(t)&&(!(r=t["text/plain"])||0!==r.indexOf("file://"))||!s.pasteImageData(e,n))&&n&&m.shouldFilterDrop(o)){var i=t["mce-internal"]||t["text/html"]||t["text/plain"];i&&(e.preventDefault(),h.setEditorTimeout(o,function(){o.undoManager.transact(function(){t["mce-internal"]&&o.execCommand("Delete"),ve(o,n),i=S.trimHtml(i),t["text/html"]?s.pasteHtml(i,a):s.pasteText(i)})}))}}}),o.on("dragstart",function(e){l.set(!0)}),o.on("dragover dragend",function(e){m.shouldPasteDataImages(o)&&!1===l.get()&&(e.preventDefault(),ve(o,ge(o,e))),"dragend"===e.type&&l.set(!1)})},be=function(e){var t=e.plugins.paste,n=m.getPreProcess(e);n&&e.on("PastePreProcess",function(e){n.call(t,t,e)});var r=m.getPostProcess(e);r&&e.on("PastePostProcess",function(e){r.call(t,t,e)})};function ye(t,n){t.on("PastePreProcess",function(e){e.content=n(t,e.content,e.internal,e.wordContent)})}function xe(e,t){if(!O.isWordContent(t))return t;var n=[];b.each(e.schema.getBlockElements(),function(e,t){n.push(t)});var r=new RegExp("(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?("+n.join("|")+")[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*","g");return t=S.filter(t,[[r,"$1"]]),t=S.filter(t,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}function Pe(e,t,n,r){if(r||n)return t;var u,a=m.getWebkitStyles(e);if(!1===m.shouldRemoveWebKitStyles(e)||"all"===a)return t;if(a&&(u=a.split(/[, ]/)),u){var c=e.dom,f=e.selection.getNode();t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(e,t,n,r){var a=c.parseStyle(c.decode(n)),i={};if("none"===u)return t+r;for(var o=0;o<u.length;o++){var s=a[u[o]],l=c.getStyle(f,u[o],!0);/color/.test(u[o])&&(s=c.toHex(s),l=c.toHex(l)),l!==s&&(i[u[o]]=s)}return(i=c.serializeStyle(i,"span"))?t+' style="'+i+'"'+r:t+r})}else t=t.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return t=t.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(e,t,n,r){return t+' style="'+n+'"'+r})}function we(n,e){n.$("a",e).find("font,u").each(function(e,t){n.dom.remove(t,!0)})}var _e=function(e){var t,n;v.webkit&&ye(e,Pe),v.ie&&(ye(e,xe),n=we,(t=e).on("PastePostProcess",function(e){n(t,e.node)}))},De=function(e,t,n){var r=n.control;r.active("text"===t.pasteFormat.get()),e.on("PastePlainTextToggle",function(e){r.active(e.state)})},Te=function(e,t){var n=function(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var o=new Array(arguments.length-1),n=1;n<arguments.length;n++)o[n-1]=arguments[n];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var a=o.concat(n);return i.apply(null,a)}}(De,e,t);e.addButton("pastetext",{active:!1,icon:"pastetext",tooltip:"Paste as text",cmd:"mceTogglePlainTextPaste",onPostRender:n}),e.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:t.pasteFormat,cmd:"mceTogglePlainTextPaste",onPostRender:n})};t.add("paste",function(e){if(!1===o(e)){var t=u(!1),n=u(!1),r=u(m.isPasteAsTextEnabled(e)?"text":"html"),a=se(e,r),i=_e(e);return Te(e,a),c(e,a,t),be(e),me(e),he(e,a,n),s(a,i)}})}();
\ No newline at end of file
+!function(v){"use strict";var l=function(t){var e=t,n=function(){return e};return{get:n,set:function(t){e=t},clone:function(){return l(n())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(t){return!(!/(^|[ ,])powerpaste([, ]|$)/.test(t.settings.plugins)||!e.get("powerpaste")||("undefined"!=typeof v.window.console&&v.window.console.log&&v.window.console.log("PowerPaste is incompatible with Paste plugin! Remove 'paste' from the 'plugins' option."),0))},s=function(t,e){return{clipboard:t,quirks:e}},f=function(t,e,n,r){return t.fire("PastePreProcess",{content:e,internal:n,wordContent:r})},d=function(t,e,n,r){return t.fire("PastePostProcess",{node:e,internal:n,wordContent:r})},u=function(t,e){return t.fire("PastePlainTextToggle",{state:e})},n=function(t,e){return t.fire("paste",{ieFake:e})},m={shouldPlainTextInform:function(t){return t.getParam("paste_plaintext_inform",!0)},shouldBlockDrop:function(t){return t.getParam("paste_block_drop",!1)},shouldPasteDataImages:function(t){return t.getParam("paste_data_images",!1)},shouldFilterDrop:function(t){return t.getParam("paste_filter_drop",!0)},getPreProcess:function(t){return t.getParam("paste_preprocess")},getPostProcess:function(t){return t.getParam("paste_postprocess")},getWebkitStyles:function(t){return t.getParam("paste_webkit_styles")},shouldRemoveWebKitStyles:function(t){return t.getParam("paste_remove_styles_if_webkit",!0)},shouldMergeFormats:function(t){return t.getParam("paste_merge_formats",!0)},isSmartPasteEnabled:function(t){return t.getParam("smart_paste",!0)},isPasteAsTextEnabled:function(t){return t.getParam("paste_as_text",!1)},getRetainStyleProps:function(t){return t.getParam("paste_retain_style_properties")},getWordValidElements:function(t){return t.getParam("paste_word_valid_elements","-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody")},shouldConvertWordFakeLists:function(t){return t.getParam("paste_convert_word_fake_lists",!0)},shouldUseDefaultFilters:function(t){return t.getParam("paste_enable_default_filters",!0)}},r=function(t,e,n){var r,o,i;"text"===e.pasteFormat.get()?(e.pasteFormat.set("html"),u(t,!1)):(e.pasteFormat.set("text"),u(t,!0),i=t,!1===n.get()&&m.shouldPlainTextInform(i)&&(o="Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.",(r=t).notificationManager.open({text:r.translate(o),type:"info"}),n.set(!0))),t.focus()},c=function(t,n,e){t.addCommand("mceTogglePlainTextPaste",function(){r(t,n,e)}),t.addCommand("mceInsertClipboardContent",function(t,e){e.content&&n.pasteHtml(e.content,e.internal),e.text&&n.pasteText(e.text)})},h=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Delay"),b=tinymce.util.Tools.resolve("tinymce.util.Tools"),o=tinymce.util.Tools.resolve("tinymce.util.VK"),t="x-tinymce/html",i="\x3c!-- "+t+" --\x3e",g=function(t){return i+t},p=function(t){return t.replace(i,"")},x=function(t){return-1!==t.indexOf(i)},P=function(){return t},w=tinymce.util.Tools.resolve("tinymce.html.Entities"),_=function(t){return t.replace(/\r?\n/g,"<br>")},D=function(t,e,n){var r=t.split(/\n\n/),o=function(t,e){var n,r=[],o="<"+t;if("object"==typeof e){for(n in e)e.hasOwnProperty(n)&&r.push(n+'="'+w.encodeAllRaw(e[n])+'"');r.length&&(o+=" "+r.join(" "))}return o+">"}(e,n),i="</"+e+">",a=b.map(r,function(t){return t.split(/\n/).join("<br />")});return 1===a.length?a[0]:b.map(a,function(t){return o+t+i}).join("")},T=function(t){return!/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(t)},C=function(t,e,n){return e?D(t,e,n):_(t)},k=tinymce.util.Tools.resolve("tinymce.html.DomParser"),S=tinymce.util.Tools.resolve("tinymce.html.Node"),O=tinymce.util.Tools.resolve("tinymce.html.Schema"),R=tinymce.util.Tools.resolve("tinymce.html.Serializer");function F(e,t){return b.each(t,function(t){e=t.constructor===RegExp?e.replace(t,""):e.replace(t[0],t[1])}),e}var E={filter:F,innerText:function(e){var n=O(),r=k({},n),o="",i=n.getShortEndedElements(),a=b.makeMap("script noscript style textarea video audio iframe object"," "),s=n.getBlockElements();return e=F(e,[/<!\[[^\]]+\]>/g]),function t(e){var n=e.name,r=e;if("br"!==n){if("wbr"!==n)if(i[n]&&(o+=" "),a[n])o+=" ";else{if(3===e.type&&(o+=e.value),!e.shortEnded&&(e=e.firstChild))for(;t(e),e=e.next;);s[n]&&r.next&&(o+="\n","p"===n&&(o+="\n"))}}else o+="\n"}(r.parse(e)),o},trimHtml:function(t){return t=F(t,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/gi,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,function(t,e,n){return e||n?"\xa0":" "}],/<br class="Apple-interchange-newline">/g,/<br>$/i])},createIdGenerator:function(t){var e=0;return function(){return t+e++}},isMsEdge:function(){return-1!==v.navigator.userAgent.indexOf(" Edge/")}};function A(e){var n,t;return t=[/^[IVXLMCD]{1,2}\.[ \u00a0]/,/^[ivxlmcd]{1,2}\.[ \u00a0]/,/^[a-z]{1,2}[\.\)][ \u00a0]/,/^[A-Z]{1,2}[\.\)][ \u00a0]/,/^[0-9]+\.[ \u00a0]/,/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/],e=e.replace(/^[\u00a0 ]+/,""),b.each(t,function(t){if(t.test(e))return!(n=!0)}),n}function I(t){var i,a,s=1;function n(t){var e="";if(3===t.type)return t.value;if(t=t.firstChild)for(;e+=n(t),t=t.next;);return e}function u(t,e){if(3===t.type&&e.test(t.value))return t.value=t.value.replace(e,""),!1;if(t=t.firstChild)do{if(!u(t,e))return!1}while(t=t.next);return!0}function e(e,n,r){var o=e._listLevel||s;o!==s&&(o<s?i&&(i=i.parent.parent):(a=i,i=null)),i&&i.name===n?i.append(e):(a=a||i,i=new S(n,1),1<r&&i.attr("start",""+r),e.wrap(i)),e.name="li",s<o&&a&&a.lastChild.append(i),s=o,function t(e){if(e._listIgnore)e.remove();else if(e=e.firstChild)for(;t(e),e=e.next;);}(e),u(e,/^\u00a0+/),u(e,/^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/),u(e,/^\u00a0+/)}for(var r=[],o=t.firstChild;null!=o;)if(r.push(o),null!==(o=o.walk()))for(;void 0!==o&&o.parent!==t;)o=o.walk();for(var l=0;l<r.length;l++)if("p"===(t=r[l]).name&&t.firstChild){var c=n(t);if(/^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(c)){e(t,"ul");continue}if(A(c)){var f=/([0-9]+)\./.exec(c),d=1;f&&(d=parseInt(f[1],10)),e(t,"ol",d);continue}if(t._listLevel){e(t,"ul",1);continue}i=null}else a=i,i=null}function M(n,r,o,i){var a,s={},t=n.dom.parseStyle(i);return b.each(t,function(t,e){switch(e){case"mso-list":(a=/\w+ \w+([0-9]+)/i.exec(i))&&(o._listLevel=parseInt(a[1],10)),/Ignore/i.test(t)&&o.firstChild&&(o._listIgnore=!0,o.firstChild._listIgnore=!0);break;case"horiz-align":e="text-align";break;case"vert-align":e="vertical-align";break;case"font-color":case"mso-foreground":e="color";break;case"mso-background":case"mso-highlight":e="background";break;case"font-weight":case"font-style":return void("normal"!==t&&(s[e]=t));case"mso-element":if(/^(comment|comment-list)$/i.test(t))return void o.remove()}0!==e.indexOf("mso-comment")?0!==e.indexOf("mso-")&&("all"===m.getRetainStyleProps(n)||r&&r[e])&&(s[e]=t):o.remove()}),/(bold)/i.test(s["font-weight"])&&(delete s["font-weight"],o.wrap(new S("b",1))),/(italic)/i.test(s["font-style"])&&(delete s["font-style"],o.wrap(new S("i",1))),(s=n.dom.serializeStyle(s,o.name))||null}var B,H,j,L,N,$={preProcess:function(t,e){return m.shouldUseDefaultFilters(t)?function(r,t){var e,o;(e=m.getRetainStyleProps(r))&&(o=b.makeMap(e.split(/[, ]/))),t=E.filter(t,[/<br class="?Apple-interchange-newline"?>/gi,/<b[^>]+id="?docs-internal-[^>]*>/gi,/<!--[\s\S]+?-->/gi,/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,[/<(\/?)s>/gi,"<$1strike>"],[/&nbsp;/gi,"\xa0"],[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,function(t,e){return 0<e.length?e.replace(/./," ").slice(Math.floor(e.length/2)).split("").join("\xa0"):""}]]);var n=m.getWordValidElements(r),i=O({valid_elements:n,valid_children:"-li[p]"});b.each(i.elements,function(t){t.attributes["class"]||(t.attributes["class"]={},t.attributesOrder.push("class")),t.attributes.style||(t.attributes.style={},t.attributesOrder.push("style"))});var a=k({},i);a.addAttributeFilter("style",function(t){for(var e,n=t.length;n--;)(e=t[n]).attr("style",M(r,o,e,e.attr("style"))),"span"===e.name&&e.parent&&!e.attributes.length&&e.unwrap()}),a.addAttributeFilter("class",function(t){for(var e,n,r=t.length;r--;)n=(e=t[r]).attr("class"),/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(n)&&e.remove(),e.attr("class",null)}),a.addNodeFilter("del",function(t){for(var e=t.length;e--;)t[e].remove()}),a.addNodeFilter("a",function(t){for(var e,n,r,o=t.length;o--;)if(n=(e=t[o]).attr("href"),r=e.attr("name"),n&&-1!==n.indexOf("#_msocom_"))e.remove();else if(n&&0===n.indexOf("file://")&&(n=n.split("#")[1])&&(n="#"+n),n||r){if(r&&!/^_?(?:toc|edn|ftn)/i.test(r)){e.unwrap();continue}e.attr({href:n,name:r})}else e.unwrap()});var s=a.parse(t);return m.shouldConvertWordFakeLists(r)&&I(s),t=R({validate:r.settings.validate},i).serialize(s)}(t,e):e},isWordContent:function(t){return/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i.test(t)||/class="OutlineElement/.test(t)||/id="?docs\-internal\-guid\-/.test(t)}},W=function(t,e){return{content:t,cancelled:e}},z=function(t,e,n,r){var o,i,a,s,u,l,c=f(t,e,n,r);return t.hasEventListeners("PastePostProcess")&&!c.isDefaultPrevented()?(o=t,i=c.content,a=n,s=r,u=o.dom.create("div",{style:"display:none"},i),l=d(o,u,a,s),W(l.node.innerHTML,l.isDefaultPrevented())):W(c.content,c.isDefaultPrevented())},U=function(t,e,n){var r=$.isWordContent(e),o=r?$.preProcess(t,e):e;return z(t,o,n,r)},V=function(t,e){var n,r;return t.insertContent((n=e,r=t.dom.create("body",{},n),b.each(r.querySelectorAll("meta"),function(t){return t.parentNode.removeChild(t)}),r.innerHTML),{merge:m.shouldMergeFormats(t),paste:!0}),!0},q=function(t){return/^https?:\/\/[\w\?\-\/+=.&%@~#]+$/i.test(t)},K=function(t){return q(t)&&/.(gif|jpe?g|png)$/.test(t)},G=function(t,e,n){return!(!1!==t.selection.isCollapsed()||!q(e)||(o=e,i=n,(r=t).undoManager.extra(function(){i(r,o)},function(){r.execCommand("mceInsertLink",!1,o)}),0));var r,o,i},X=function(t,e,n){return!!K(e)&&(o=e,i=n,(r=t).undoManager.extra(function(){i(r,o)},function(){r.insertContent('<img src="'+o+'">')}),!0);var r,o,i},Y=function(t,e){var n,r;!1===m.isSmartPasteEnabled(t)?V(t,e):(n=t,r=e,b.each([G,X,V],function(t){return!0!==t(n,r,V)}))},Z=function(t){return function(){return t}},J=Z(!1),Q=Z(!0),tt=J,et=Q,nt=function(){return rt},rt=(L={fold:function(t,e){return t()},is:tt,isSome:tt,isNone:et,getOr:j=function(t){return t},getOrThunk:H=function(t){return t()},getOrDie:function(t){throw new Error(t||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:j,orThunk:H,map:nt,ap:nt,each:function(){},bind:nt,flatten:nt,exists:tt,forall:et,filter:nt,equals:B=function(t){return t.isNone()},equals_:B,toArray:function(){return[]},toString:Z("none()")},Object.freeze&&Object.freeze(L),L),ot=function(n){var t=function(){return n},e=function(){return o},r=function(t){return t(n)},o={fold:function(t,e){return e(n)},is:function(t){return n===t},isSome:et,isNone:tt,getOr:t,getOrThunk:t,getOrDie:t,getOrNull:t,getOrUndefined:t,or:e,orThunk:e,map:function(t){return ot(t(n))},ap:function(t){return t.fold(nt,function(t){return ot(t(n))})},each:function(t){t(n)},bind:r,flatten:t,exists:r,forall:r,filter:function(t){return t(n)?o:rt},equals:function(t){return t.is(n)},equals_:function(t,e){return t.fold(tt,function(t){return e(n,t)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},it={some:ot,none:nt,from:function(t){return null===t||t===undefined?rt:ot(t)}},at=(N="function",function(t){return function(t){if(null===t)return"null";var e=typeof t;return"object"===e&&Array.prototype.isPrototypeOf(t)?"array":"object"===e&&String.prototype.isPrototypeOf(t)?"string":e}(t)===N}),st=function(t,e){for(var n=t.length,r=new Array(n),o=0;o<n;o++){var i=t[o];r[o]=e(i,o,t)}return r},ut=function(t,e){for(var n=0,r=t.length;n<r;n++)e(t[n],n,t)},lt=Array.prototype.slice,ct=at(Array.from)?Array.from:function(t){return lt.call(t)},ft=function(t){var n=it.none(),e=[],r=function(t){o()?a(t):e.push(t)},o=function(){return n.isSome()},i=function(t){ut(t,a)},a=function(e){n.each(function(t){v.setTimeout(function(){e(t)},0)})};return t(function(t){n=it.some(t),i(e),e=[]}),{get:r,map:function(n){return ft(function(e){r(function(t){e(n(t))})})},isReady:o}},dt={nu:ft,pure:function(e){return ft(function(t){t(e)})}},mt=function(e){var t=function(t){var r;e((r=t,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=this;v.setTimeout(function(){r.apply(n,t)},0)}))},n=function(){return dt.nu(t)};return{map:function(r){return mt(function(n){t(function(t){var e=r(t);n(e)})})},bind:function(n){return mt(function(e){t(function(t){n(t).get(e)})})},anonBind:function(n){return mt(function(e){t(function(t){n.get(e)})})},toLazy:n,toCached:function(){var e=null;return mt(function(t){null===e&&(e=n()),e.get(t)})},get:t}},gt={nu:mt,pure:function(e){return mt(function(t){t(e)})}},pt=function(a,t){return t(function(r){var o=[],i=0;0===a.length?r([]):ut(a,function(t,e){var n;t.get((n=e,function(t){o[n]=t,++i>=a.length&&r(o)}))})})},vt=function(t,e){var n=st(t,e);return pt(n,gt.nu)},ht=function(t,e,n){var r=n||x(e),o=U(t,p(e),r);!1===o.cancelled&&Y(t,o.content)},yt=function(t,e){e=t.dom.encode(e).replace(/\r\n/g,"\n"),e=C(e,t.settings.forced_root_block,t.settings.forced_root_block_attrs),ht(t,e,!1)},bt=function(t){var e={};if(t){if(t.getData){var n=t.getData("Text");n&&0<n.length&&-1===n.indexOf("data:text/mce-internal,")&&(e["text/plain"]=n)}if(t.types)for(var r=0;r<t.types.length;r++){var o=t.types[r];try{e[o]=t.getData(o)}catch(i){e[o]=""}}}return e},xt=function(t,e){return e in t&&0<t[e].length},Pt=function(t){return xt(t,"text/html")||xt(t,"text/plain")},wt=E.createIdGenerator("mceclip"),_t=function(e,t,n){var r,o,i,a,s="paste"===t.type?t.clipboardData:t.dataTransfer;if(e.settings.paste_data_images&&s){var u=(i=(o=s).items?st(ct(o.items),function(t){return t.getAsFile()}):[],a=o.files?ct(o.files):[],function(t,e){for(var n=[],r=0,o=t.length;r<o;r++){var i=t[r];e(i,r,t)&&n.push(i)}return n}(0<i.length?i:a,function(t){return/^image\/(jpeg|png|gif|bmp)$/.test(t.type)}));if(0<u.length)return t.preventDefault(),(r=u,vt(r,function(r){return gt.nu(function(t){var e=r.getAsFile?r.getAsFile():r,n=new window.FileReader;n.onload=function(){t({blob:e,uri:n.result})},n.readAsDataURL(e)})})).get(function(t){n&&e.selection.setRng(n),ut(t,function(t){!function(t,e){var n,r,o,i,a,s,u,l=(n=e.uri,-1!==(r=n.indexOf(","))?n.substr(r+1):null),c=wt(),f=t.settings.images_reuse_filename&&e.blob.name?(o=t,i=e.blob.name,(a=i.match(/([\s\S]+?)\.(?:jpeg|jpg|png|gif)$/i))?o.dom.encode(a[1]):null):c,d=new v.Image;if(d.src=e.uri,s=t.settings,u=d,!s.images_dataimg_filter||s.images_dataimg_filter(u)){var m,g=t.editorUpload.blobCache,p=void 0;(m=g.findFirst(function(t){return t.base64()===l}))?p=m:(p=g.create(c,e.blob,l,f),g.add(p)),ht(t,'<img src="'+p.blobUri()+'">',!1)}else ht(t,'<img src="'+e.uri+'">',!1)}(e,t)})}),!0}return!1},Dt=function(t){return o.metaKeyPressed(t)&&86===t.keyCode||t.shiftKey&&45===t.keyCode},Tt=function(c,f,d){var m,g=0;function p(t,e,n,r){var o,i;xt(t,"text/html")?o=t["text/html"]:(o=f.getHtml(),r=r||x(o),f.isDefaultContent(o)&&(n=!0)),o=E.trimHtml(o),f.remove(),i=!1===r&&T(o),o.length&&!i||(n=!0),n&&(o=xt(t,"text/plain")&&i?t["text/plain"]:E.innerText(o)),f.isDefaultContent(o)?e||c.windowManager.alert("Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents."):n?yt(c,o):ht(c,o,r)}c.on("keydown",function(t){function e(t){Dt(t)&&!t.isDefaultPrevented()&&f.remove()}if(Dt(t)&&!t.isDefaultPrevented()){if((m=t.shiftKey&&86===t.keyCode)&&h.webkit&&-1!==v.navigator.userAgent.indexOf("Version/"))return;if(t.stopImmediatePropagation(),g=(new Date).getTime(),h.ie&&m)return t.preventDefault(),void n(c,!0);f.remove(),f.create(),c.once("keyup",e),c.once("paste",function(){c.off("keyup",e)})}}),c.on("paste",function(t){var e,n,r,o=(new Date).getTime(),i=(e=c,n=bt(t.clipboardData||e.getDoc().dataTransfer),E.isMsEdge()?b.extend(n,{"text/html":""}):n),a=(new Date).getTime()-o,s=(new Date).getTime()-g-a<1e3,u="text"===d.get()||m,l=xt(i,P());m=!1,t.isDefaultPrevented()||(r=t.clipboardData,-1!==v.navigator.userAgent.indexOf("Android")&&r&&r.items&&0===r.items.length)?f.remove():Pt(i)||!_t(c,t,f.getLastRng()||c.selection.getRng())?(s||t.preventDefault(),!h.ie||s&&!t.ieFake||xt(i,"text/html")||(f.create(),c.dom.bind(f.getEl(),"paste",function(t){t.stopPropagation()}),c.getDoc().execCommand("Paste",!1,null),i["text/html"]=f.getHtml()),xt(i,"text/html")?(t.preventDefault(),l||(l=x(i["text/html"])),p(i,s,u,l)):y.setEditorTimeout(c,function(){p(i,s,u,l)},0)):f.remove()})},Ct=function(t){return h.ie&&t.inline?v.document.body:t.getBody()},kt=function(e,t,n){var r;Ct(r=e)!==r.getBody()&&e.dom.bind(t,"paste keyup",function(t){Rt(e,n)||e.fire("paste")})},St=function(t){return t.dom.get("mcepastebin")},Ot=function(t,e){return e===t},Rt=function(t,e){var n,r=St(t);return(n=r)&&"mcepastebin"===n.id&&Ot(e,r.innerHTML)},Ft=function(a){var s=l(null),u="%MCEPASTEBIN%";return{create:function(){return e=s,n=u,o=(t=a).dom,i=t.getBody(),e.set(t.selection.getRng()),r=t.dom.add(Ct(t),"div",{id:"mcepastebin","class":"mce-pastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0"},n),(h.ie||h.gecko)&&o.setStyle(r,"left","rtl"===o.getStyle(i,"direction",!0)?65535:-65535),o.bind(r,"beforedeactivate focusin focusout",function(t){t.stopPropagation()}),kt(t,r,n),r.focus(),void t.selection.select(r,!0);var t,e,n,r,o,i},remove:function(){return function(t,e){if(St(t)){for(var n=void 0,r=e.get();n=t.dom.get("mcepastebin");)t.dom.remove(n),t.dom.unbind(n);r&&t.selection.setRng(r)}e.set(null)}(a,s)},getEl:function(){return St(a)},getHtml:function(){return function(n){var e,t,r,o,i,a=function(t,e){t.appendChild(e),n.dom.remove(e,!0)};for(t=b.grep(Ct(n).childNodes,function(t){return"mcepastebin"===t.id}),e=t.shift(),b.each(t,function(t){a(e,t)}),r=(o=n.dom.select("div[id=mcepastebin]",e)).length-1;0<=r;r--)i=n.dom.create("div"),e.insertBefore(i,o[r]),a(i,o[r]);return e?e.innerHTML:""}(a)},getLastRng:function(){return s.get()},isDefault:function(){return Rt(a,u)},isDefaultContent:function(t){return Ot(u,t)}}},Et=function(n,t){var e=Ft(n);return n.on("preInit",function(){return Tt(a=n,e,t),void a.parser.addNodeFilter("img",function(t,e,n){var r,o=function(t){t.attr("data-mce-object")||s===h.transparentSrc||t.remove()};if(!a.settings.paste_data_images&&(r=n).data&&!0===r.data.paste)for(var i=t.length;i--;)(s=t[i].attributes.map.src)&&(0===s.indexOf("webkit-fake-url")?o(t[i]):a.settings.allow_html_data_urls||0!==s.indexOf("data:")||o(t[i]))});var a,s}),{pasteFormat:t,pasteHtml:function(t,e){return ht(n,t,e)},pasteText:function(t){return yt(n,t)},pasteImageData:function(t,e){return _t(n,t,e)},getDataTransferItems:bt,hasHtmlOrText:Pt,hasContentType:xt}},At=function(){},It=function(t,e,n){if(r=t,!1!==h.iOS||r===undefined||"function"!=typeof r.setData||!0===E.isMsEdge())return!1;try{return t.clearData(),t.setData("text/html",e),t.setData("text/plain",n),t.setData(P(),e),!0}catch(o){return!1}var r},Mt=function(t,e,n,r){It(t.clipboardData,e.html,e.text)?(t.preventDefault(),r()):n(e.html,r)},Bt=function(s){return function(t,e){var n=g(t),r=s.dom.create("div",{contenteditable:"false","data-mce-bogus":"all"}),o=s.dom.create("div",{contenteditable:"true"},n);s.dom.setStyles(r,{position:"fixed",top:"0",left:"-3000px",width:"1000px",overflow:"hidden"}),r.appendChild(o),s.dom.add(s.getBody(),r);var i=s.selection.getRng();o.focus();var a=s.dom.createRng();a.selectNodeContents(o),s.selection.setRng(a),setTimeout(function(){s.selection.setRng(i),r.parentNode.removeChild(r),e()},0)}},Ht=function(t){return{html:t.selection.getContent({contextual:!0}),text:t.selection.getContent({format:"text"})}},jt=function(t){return!t.selection.isCollapsed()||!!(e=t).dom.getParent(e.selection.getStart(),"td[data-mce-selected],th[data-mce-selected]",e.getBody());var e},Lt=function(t){var e,n;t.on("cut",(e=t,function(t){jt(e)&&Mt(t,Ht(e),Bt(e),function(){setTimeout(function(){e.execCommand("Delete")},0)})})),t.on("copy",(n=t,function(t){jt(n)&&Mt(t,Ht(n),Bt(n),At)}))},Nt=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),$t=function(t,e){return Nt.getCaretRangeFromPoint(e.clientX,e.clientY,t.getDoc())},Wt=function(t,e){t.focus(),t.selection.setRng(e)},zt=function(a,s,u){m.shouldBlockDrop(a)&&a.on("dragend dragover draggesture dragdrop drop drag",function(t){t.preventDefault(),t.stopPropagation()}),m.shouldPasteDataImages(a)||a.on("drop",function(t){var e=t.dataTransfer;e&&e.files&&0<e.files.length&&t.preventDefault()}),a.on("drop",function(t){var e,n;if(n=$t(a,t),!t.isDefaultPrevented()&&!u.get()){e=s.getDataTransferItems(t.dataTransfer);var r,o=s.hasContentType(e,P());if((s.hasHtmlOrText(e)&&(!(r=e["text/plain"])||0!==r.indexOf("file://"))||!s.pasteImageData(t,n))&&n&&m.shouldFilterDrop(a)){var i=e["mce-internal"]||e["text/html"]||e["text/plain"];i&&(t.preventDefault(),y.setEditorTimeout(a,function(){a.undoManager.transact(function(){e["mce-internal"]&&a.execCommand("Delete"),Wt(a,n),i=E.trimHtml(i),e["text/html"]?s.pasteHtml(i,o):s.pasteText(i)})}))}}}),a.on("dragstart",function(t){u.set(!0)}),a.on("dragover dragend",function(t){m.shouldPasteDataImages(a)&&!1===u.get()&&(t.preventDefault(),Wt(a,$t(a,t))),"dragend"===t.type&&u.set(!1)})},Ut=function(t){var e=t.plugins.paste,n=m.getPreProcess(t);n&&t.on("PastePreProcess",function(t){n.call(e,e,t)});var r=m.getPostProcess(t);r&&t.on("PastePostProcess",function(t){r.call(e,e,t)})};function Vt(e,n){e.on("PastePreProcess",function(t){t.content=n(e,t.content,t.internal,t.wordContent)})}function qt(t,e){if(!$.isWordContent(e))return e;var n=[];b.each(t.schema.getBlockElements(),function(t,e){n.push(e)});var r=new RegExp("(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*(<\\/?("+n.join("|")+")[^>]*>)(?:<br>&nbsp;[\\s\\r\\n]+|<br>)*","g");return e=E.filter(e,[[r,"$1"]]),e=E.filter(e,[[/<br><br>/g,"<BR><BR>"],[/<br>/g," "],[/<BR><BR>/g,"<br>"]])}function Kt(t,e,n,r){if(r||n)return e;var l,o=m.getWebkitStyles(t);if(!1===m.shouldRemoveWebKitStyles(t)||"all"===o)return e;if(o&&(l=o.split(/[, ]/)),l){var c=t.dom,f=t.selection.getNode();e=e.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,function(t,e,n,r){var o=c.parseStyle(c.decode(n)),i={};if("none"===l)return e+r;for(var a=0;a<l.length;a++){var s=o[l[a]],u=c.getStyle(f,l[a],!0);/color/.test(l[a])&&(s=c.toHex(s),u=c.toHex(u)),u!==s&&(i[l[a]]=s)}return(i=c.serializeStyle(i,"span"))?e+' style="'+i+'"'+r:e+r})}else e=e.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi,"$1$3");return e=e.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi,function(t,e,n,r){return e+' style="'+n+'"'+r})}function Gt(n,t){n.$("a",t).find("font,u").each(function(t,e){n.dom.remove(e,!0)})}var Xt=function(t){var e,n;h.webkit&&Vt(t,Kt),h.ie&&(Vt(t,qt),n=Gt,(e=t).on("PastePostProcess",function(t){n(e,t.node)}))},Yt=function(t,e,n){var r=n.control;r.active("text"===e.pasteFormat.get()),t.on("PastePlainTextToggle",function(t){r.active(t.state)})},Zt=function(t,e){var n=function(r){for(var o=[],t=1;t<arguments.length;t++)o[t-1]=arguments[t];return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=o.concat(t);return r.apply(null,n)}}(Yt,t,e);t.addButton("pastetext",{active:!1,icon:"pastetext",tooltip:"Paste as text",cmd:"mceTogglePlainTextPaste",onPostRender:n}),t.addMenuItem("pastetext",{text:"Paste as text",selectable:!0,active:e.pasteFormat,cmd:"mceTogglePlainTextPaste",onPostRender:n})};e.add("paste",function(t){if(!1===a(t)){var e=l(!1),n=l(!1),r=l(m.isPasteAsTextEnabled(t)?"text":"html"),o=Et(t,r),i=Xt(t);return Zt(t,o),c(t,o,e),Ut(t),Lt(t),zt(t,o,n),s(o,i)}})}(window);
\ No newline at end of file

plugins/spellchecker/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var spellchecker = (function () {
+var spellchecker = (function (domGlobals) {
'use strict';
var Cell = function (initial) {
@@ -24,8 +24,8 @@
var hasProPlugin = function (editor) {
if (/(^|[ ,])tinymcespellchecker([, ]|$)/.test(editor.settings.plugins) && global.get('tinymcespellchecker')) {
- if (typeof window.console !== 'undefined' && window.console.log) {
- window.console.log('Spell Checker Pro is incompatible with Spell Checker plugin! ' + 'Remove \'spellchecker\' from the \'plugins\' option.');
+ if (typeof domGlobals.window.console !== 'undefined' && domGlobals.window.console.log) {
+ domGlobals.window.console.log('Spell Checker Pro is incompatible with Spell Checker plugin! ' + 'Remove \'spellchecker\' from the \'plugins\' option.');
}
return true;
} else {
@@ -474,7 +474,9 @@
checkIfFinished(editor, startedState, textMatcherState);
};
var finish = function (editor, startedState, textMatcherState) {
+ var bookmark = editor.selection.getBookmark();
getTextMatcher(editor, textMatcherState).reset();
+ editor.selection.moveToBookmark(bookmark);
textMatcherState.set(null);
if (startedState.get()) {
startedState.set(false);
@@ -528,6 +530,7 @@
suggestions: suggestions,
hasDictionarySupport: hasDictionarySupport
});
+ var bookmark = editor.selection.getBookmark();
getTextMatcher(editor, textMatcherState).find(Settings.getSpellcheckerWordcharPattern(editor)).filter(function (match) {
return !!suggestions[match.text];
}).wrap(function (match) {
@@ -537,6 +540,7 @@
'data-mce-word': match.text
});
});
+ editor.selection.moveToBookmark(bookmark);
startedState.set(true);
Events.fireSpellcheckStart(editor);
};
@@ -701,7 +705,7 @@
suggestionsMenu = null;
}
});
- suggestionsMenu.renderTo(document.body);
+ suggestionsMenu.renderTo(domGlobals.document.body);
var pos = global$4.DOM.getPos(editor.getContentAreaContainer());
var targetPos = editor.dom.getPos(spans[0]);
var root = editor.dom.getRoot();
@@ -751,5 +755,5 @@
return Plugin;
-}());
+}(window));
})();

plugins/spellchecker/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var c=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return c(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(e){return!(!/(^|[ ,])tinymcespellchecker([, ]|$)/.test(e.settings.plugins)||!t.get("tinymcespellchecker")||("undefined"!=typeof window.console&&window.console.log&&window.console.log("Spell Checker Pro is incompatible with Spell Checker plugin! Remove 'spellchecker' from the 'plugins' option."),0))},h=function(e){return e.getParam("spellchecker_languages","English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv")},l=function(e){var t=e.getParam("language","en");return e.getParam("spellchecker_language",t)},d=function(e){return e.getParam("spellchecker_rpc_url")},f=function(e){return e.getParam("spellchecker_callback")},s=function(e){var t=new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`\xa7\xa9\xab\xae\xb1\xb6\xb7\xb8\xbb\xbc\xbd\xbe\xbf\xd7\xf7\xa4\u201d\u201c\u201e\xa0\u2002\u2003\u2009]+',"g");return e.getParam("spellchecker_wordchar_pattern",t)},g=tinymce.util.Tools.resolve("tinymce.util.Tools"),m=tinymce.util.Tools.resolve("tinymce.util.URI"),p=tinymce.util.Tools.resolve("tinymce.util.XHR"),u=function(e){return e.fire("SpellcheckStart")},r=function(e){return e.fire("SpellcheckEnd")};function x(e){return e&&1===e.nodeType&&"false"===e.contentEditable}var v,o=function(c,r){var n,o,f,h,g,i=[],v=r.dom;function a(e,t){if(!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");return{start:e.index,end:e.index+e[0].length,text:e[0],data:t}}function l(e){var t=c.getElementsByTagName("*"),n=[];e="number"==typeof e?""+e:null;for(var r=0;r<t.length;r++){var o=t[r],i=o.getAttribute("data-mce-index");null!==i&&i.length&&-1!==o.className.indexOf("mce-spellchecker-word")&&(i!==e&&null!==e||n.push(o))}return n}function s(e){for(var t=i.length;t--;)if(i[t]===e)return t;return-1}function t(e){for(var t=0,n=i.length;t<n&&!1!==e(i[t],t);t++);return this}function u(e){var t,n,r=l(e?s(e):null);for(t=r.length;t--;)(n=r[t]).parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n);return this}function d(e){var t=l(s(e)),n=r.dom.createRng();return n.setStartBefore(t[0]),n.setEndAfter(t[t.length-1]),n}return f=r.schema.getBlockElements(),h=r.schema.getWhiteSpaceElements(),g=r.schema.getShortEndedElements(),{text:o=function e(t){var n;if(3===t.nodeType)return t.data;if(h[t.nodeName]&&!f[t.nodeName])return"";if(x(t))return"\n";if(n="",(f[t.nodeName]||g[t.nodeName])&&(n+="\n"),t=t.firstChild)for(;n+=e(t),t=t.nextSibling;);return n}(c),matches:i,each:t,filter:function(n){var r=[];return t(function(e,t){n(e,t)&&r.push(e)}),i=r,this},reset:function(){return i.splice(0,i.length),u(),this},matchFromElement:function(e){return i[e.getAttribute("data-mce-index")]},elementFromMatch:function(e){return l(s(e))[0]},find:function(e,t){if(o&&e.global)for(;n=e.exec(o);)i.push(a(n,t));return this},add:function(e,t,n){return i.push({start:e,end:e+t,text:o.substr(e,t),data:n}),this},wrap:function(e){return i.length&&function(e,t,n){var r,o,i,c,a,l=[],s=0,u=e,d=0;(t=t.slice(0)).sort(function(e,t){return e.start-t.start}),a=t.shift();e:for(;;){if((f[u.nodeName]||g[u.nodeName]||x(u))&&s++,3===u.nodeType&&(!o&&u.length+s>=a.end?(o=u,c=a.end-s):r&&l.push(u),!r&&u.length+s>a.start&&(r=u,i=a.start-s),s+=u.length),r&&o){if(u=n({startNode:r,startNodeIndex:i,endNode:o,endNodeIndex:c,innerNodes:l,match:a.text,matchIndex:d}),s-=o.length-c,o=r=null,l=[],d++,!(a=t.shift()))break}else if(h[u.nodeName]&&!f[u.nodeName]||!u.firstChild){if(u.nextSibling){u=u.nextSibling;continue}}else if(!x(u)){u=u.firstChild;continue}for(;;){if(u.nextSibling){u=u.nextSibling;break}if(u.parentNode===e)break e;u=u.parentNode}}}(c,i,function(o){function p(e,t){var n=i[t];n.stencil||(n.stencil=o(n));var r=n.stencil.cloneNode(!1);return r.setAttribute("data-mce-index",t),e&&r.appendChild(v.doc.createTextNode(e)),r}return function(e){var t,n,r,o=e.startNode,i=e.endNode,c=e.matchIndex,a=v.doc;if(o===i){var l=o;r=l.parentNode,0<e.startNodeIndex&&(t=a.createTextNode(l.data.substring(0,e.startNodeIndex)),r.insertBefore(t,l));var s=p(e.match,c);return r.insertBefore(s,l),e.endNodeIndex<l.length&&(n=a.createTextNode(l.data.substring(e.endNodeIndex)),r.insertBefore(n,l)),l.parentNode.removeChild(l),s}t=a.createTextNode(o.data.substring(0,e.startNodeIndex)),n=a.createTextNode(i.data.substring(e.endNodeIndex));for(var u=p(o.data.substring(e.startNodeIndex),c),d=0,f=e.innerNodes.length;d<f;++d){var h=e.innerNodes[d],g=p(h.data,c);h.parentNode.replaceChild(g,h)}var m=p(i.data.substring(0,e.endNodeIndex),c);return(r=o.parentNode).insertBefore(t,o),r.insertBefore(u,o),r.removeChild(o),(r=i.parentNode).insertBefore(m,i),r.insertBefore(n,i),r.removeChild(i),m}}(e)),this},unwrap:u,replace:function(e,t){var n=d(e);return n.deleteContents(),0<t.length&&n.insertNode(r.dom.doc.createTextNode(t)),n},rangeFromMatch:d,indexOf:s}},N=function(e,t){if(!t.get()){var n=o(e.getBody(),e);t.set(n)}return t.get()},k=function(e,t,n,r,o,i,c){var a,l,s,u=f(e);(u||(a=e,l=t,s=n,function(e,t,n,r){var o={method:e,lang:s.get()},i="";o["addToDictionary"===e?"word":"text"]=t,g.each(o,function(e,t){i&&(i+="&"),i+=t+"="+encodeURIComponent(e)}),p.send({url:new m(l).toAbsolute(d(a)),type:"post",content_type:"application/x-www-form-urlencoded",data:i,success:function(e){if(e=JSON.parse(e))e.error?r(e.error):n(e);else{var t=a.translate("Server response wasn't proper JSON.");r(t)}},error:function(){var e=a.translate("The spelling service was not found: (")+d(a)+a.translate(")");r(e)}})})).call(e.plugins.spellchecker,r,o,i,c)},y=function(e,t,n){e.dom.select("span.mce-spellchecker-word").length||S(e,t,n)},S=function(e,t,n){if(N(e,n).reset(),n.set(null),t.get())return t.set(!1),r(e),!0},w=function(e){var t=e.getAttribute("data-mce-index");return"number"==typeof t?""+t:t},b=function(t,e,n,r,o){var i,c;if("string"!=typeof o&&o.words?(c=!!o.dictionary,i=o.words):i=o,t.setProgressState(!1),function(e){for(var t in e)return!1;return!0}(i)){var a=t.translate("No misspellings found.");return t.notificationManager.open({text:a,type:"info"}),void e.set(!1)}r.set({suggestions:i,hasDictionarySupport:c}),N(t,n).find(s(t)).filter(function(e){return!!i[e.text]}).wrap(function(e){return t.dom.create("span",{"class":"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":e.text})}),e.set(!0),u(t)},T={spellcheck:function(t,e,n,r,o,i){S(t,n,r)||(t.setProgressState(!0),k(t,e,i,"spellcheck",N(t,r).text,function(e){b(t,n,r,o,e)},function(e){t.notificationManager.open({text:e,type:"error"}),t.setProgressState(!1),S(t,n,r)}),t.focus())},checkIfFinished:y,addToDictionary:function(t,e,n,r,o,i,c){t.setProgressState(!0),k(t,e,o,"addToDictionary",i,function(){t.setProgressState(!1),t.dom.remove(c,!0),y(t,n,r)},function(e){t.notificationManager.open({text:e,type:"error"}),t.setProgressState(!1)})},ignoreWord:function(t,e,n,r,o,i){t.selection.collapse(),i?g.each(t.dom.select("span.mce-spellchecker-word"),function(e){e.getAttribute("data-mce-word")===r&&t.dom.remove(e,!0)}):t.dom.remove(o,!0),y(t,e,n)},findSpansByIndex:function(e,t){var n,r=[];if((n=g.toArray(e.getBody().getElementsByTagName("span"))).length)for(var o=0;o<n.length;o++){var i=w(n[o]);null!==i&&i.length&&i===t.toString()&&r.push(n[o])}return r},getElmIndex:w,markErrors:b},I=function(t,n,r,o,e,i){return{getTextMatcher:function(){return o.get()},getWordCharPattern:function(){return s(t)},markErrors:function(e){T.markErrors(t,n,o,r,e)},getLanguage:function(){return e.get()}}},E=function(e,t,n,r,o,i){e.addCommand("mceSpellCheck",function(){T.spellcheck(e,t,n,r,o,i)})},P=function(n,e,r,t,o,i){var c,a,l,s,u=(l=n,c=g.map(h(l).split(","),function(e){return{name:(e=e.split("="))[0],value:e[1]}}),a=[],g.each(c,function(e){a.push({selectable:!0,text:e.name,data:e.value})}),a),d=function(){T.spellcheck(n,e,r,t,i,o)},f={tooltip:"Spellcheck",onclick:d,onPostRender:function(e){var t=e.control;n.on("SpellcheckStart SpellcheckEnd",function(){t.active(r.get())})}};1<u.length&&(f.type="splitbutton",f.menu=u,f.onshow=(s=o,function(e){var t=s.get();e.control.items().each(function(e){e.active(e.settings.data===t)})}),f.onselect=function(e){o.set(e.control.settings.data)}),n.addButton("spellchecker",f),n.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:d,selectable:!0,onPostRender:function(){var e=this;e.active(r.get()),n.on("SpellcheckStart SpellcheckEnd",function(){e.active(r.get())})}})},B=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),C=tinymce.util.Tools.resolve("tinymce.ui.Factory"),D=function(o,i,c,a,l,s){o.on("click",function(e){var t=e.target;if("mce-spellchecker-word"===t.className){e.preventDefault();var n=T.findSpansByIndex(o,T.getElmIndex(t));if(0<n.length){var r=o.dom.createRng();r.setStartBefore(n[0]),r.setEndAfter(n[n.length-1]),o.selection.setRng(r),function(t,e,n,r,o,i,c,a){var l=[],s=n.get().suggestions[c];g.each(s,function(e){l.push({text:e,onclick:function(){t.insertContent(t.dom.encode(e)),t.dom.remove(a),T.checkIfFinished(t,r,o)}})}),l.push({text:"-"}),n.get().hasDictionarySupport&&l.push({text:"Add to Dictionary",onclick:function(){T.addToDictionary(t,e,r,o,i,c,a)}}),l.push.apply(l,[{text:"Ignore",onclick:function(){T.ignoreWord(t,r,o,c,a)}},{text:"Ignore all",onclick:function(){T.ignoreWord(t,r,o,c,a,!0)}}]),(v=C.create("menu",{items:l,context:"contextmenu",onautohide:function(e){-1!==e.target.className.indexOf("spellchecker")&&e.preventDefault()},onhide:function(){v.remove(),v=null}})).renderTo(document.body);var u=B.DOM.getPos(t.getContentAreaContainer()),d=t.dom.getPos(a[0]),f=t.dom.getRoot();"BODY"===f.nodeName?(d.x-=f.ownerDocument.documentElement.scrollLeft||f.scrollLeft,d.y-=f.ownerDocument.documentElement.scrollTop||f.scrollTop):(d.x-=f.scrollLeft,d.y-=f.scrollTop),u.x+=d.x,u.y+=d.y,v.moveTo(u.x,u.y+a[0].offsetHeight)}(o,i,c,a,l,s,t.getAttribute("data-mce-word"),n)}}})};t.add("spellchecker",function(e,t){if(!1===a(e)){var n=c(!1),r=c(l(e)),o=c(null),i=c(null);return P(e,t,n,o,r,i),D(e,t,i,n,o,r),E(e,t,n,o,i,r),I(e,n,i,o,r,t)}})}();
\ No newline at end of file
+!function(g){"use strict";var c=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return c(n())}}},t=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=function(e){return!(!/(^|[ ,])tinymcespellchecker([, ]|$)/.test(e.settings.plugins)||!t.get("tinymcespellchecker")||("undefined"!=typeof g.window.console&&g.window.console.log&&g.window.console.log("Spell Checker Pro is incompatible with Spell Checker plugin! Remove 'spellchecker' from the 'plugins' option."),0))},h=function(e){return e.getParam("spellchecker_languages","English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv")},l=function(e){var t=e.getParam("language","en");return e.getParam("spellchecker_language",t)},d=function(e){return e.getParam("spellchecker_rpc_url")},f=function(e){return e.getParam("spellchecker_callback")},s=function(e){var t=new RegExp('[^\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`\xa7\xa9\xab\xae\xb1\xb6\xb7\xb8\xbb\xbc\xbd\xbe\xbf\xd7\xf7\xa4\u201d\u201c\u201e\xa0\u2002\u2003\u2009]+',"g");return e.getParam("spellchecker_wordchar_pattern",t)},m=tinymce.util.Tools.resolve("tinymce.util.Tools"),p=tinymce.util.Tools.resolve("tinymce.util.URI"),v=tinymce.util.Tools.resolve("tinymce.util.XHR"),u=function(e){return e.fire("SpellcheckStart")},o=function(e){return e.fire("SpellcheckEnd")};function x(e){return e&&1===e.nodeType&&"false"===e.contentEditable}var k,r=function(c,r){var n,o,f,g,h,i=[],v=r.dom;function a(e,t){if(!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");return{start:e.index,end:e.index+e[0].length,text:e[0],data:t}}function l(e){var t=c.getElementsByTagName("*"),n=[];e="number"==typeof e?""+e:null;for(var r=0;r<t.length;r++){var o=t[r],i=o.getAttribute("data-mce-index");null!==i&&i.length&&-1!==o.className.indexOf("mce-spellchecker-word")&&(i!==e&&null!==e||n.push(o))}return n}function s(e){for(var t=i.length;t--;)if(i[t]===e)return t;return-1}function t(e){for(var t=0,n=i.length;t<n&&!1!==e(i[t],t);t++);return this}function u(e){var t,n,r=l(e?s(e):null);for(t=r.length;t--;)(n=r[t]).parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n);return this}function d(e){var t=l(s(e)),n=r.dom.createRng();return n.setStartBefore(t[0]),n.setEndAfter(t[t.length-1]),n}return f=r.schema.getBlockElements(),g=r.schema.getWhiteSpaceElements(),h=r.schema.getShortEndedElements(),{text:o=function e(t){var n;if(3===t.nodeType)return t.data;if(g[t.nodeName]&&!f[t.nodeName])return"";if(x(t))return"\n";if(n="",(f[t.nodeName]||h[t.nodeName])&&(n+="\n"),t=t.firstChild)for(;n+=e(t),t=t.nextSibling;);return n}(c),matches:i,each:t,filter:function(n){var r=[];return t(function(e,t){n(e,t)&&r.push(e)}),i=r,this},reset:function(){return i.splice(0,i.length),u(),this},matchFromElement:function(e){return i[e.getAttribute("data-mce-index")]},elementFromMatch:function(e){return l(s(e))[0]},find:function(e,t){if(o&&e.global)for(;n=e.exec(o);)i.push(a(n,t));return this},add:function(e,t,n){return i.push({start:e,end:e+t,text:o.substr(e,t),data:n}),this},wrap:function(e){return i.length&&function(e,t,n){var r,o,i,c,a,l=[],s=0,u=e,d=0;(t=t.slice(0)).sort(function(e,t){return e.start-t.start}),a=t.shift();e:for(;;){if((f[u.nodeName]||h[u.nodeName]||x(u))&&s++,3===u.nodeType&&(!o&&u.length+s>=a.end?(o=u,c=a.end-s):r&&l.push(u),!r&&u.length+s>a.start&&(r=u,i=a.start-s),s+=u.length),r&&o){if(u=n({startNode:r,startNodeIndex:i,endNode:o,endNodeIndex:c,innerNodes:l,match:a.text,matchIndex:d}),s-=o.length-c,o=r=null,l=[],d++,!(a=t.shift()))break}else if(g[u.nodeName]&&!f[u.nodeName]||!u.firstChild){if(u.nextSibling){u=u.nextSibling;continue}}else if(!x(u)){u=u.firstChild;continue}for(;;){if(u.nextSibling){u=u.nextSibling;break}if(u.parentNode===e)break e;u=u.parentNode}}}(c,i,function(o){function p(e,t){var n=i[t];n.stencil||(n.stencil=o(n));var r=n.stencil.cloneNode(!1);return r.setAttribute("data-mce-index",t),e&&r.appendChild(v.doc.createTextNode(e)),r}return function(e){var t,n,r,o=e.startNode,i=e.endNode,c=e.matchIndex,a=v.doc;if(o===i){var l=o;r=l.parentNode,0<e.startNodeIndex&&(t=a.createTextNode(l.data.substring(0,e.startNodeIndex)),r.insertBefore(t,l));var s=p(e.match,c);return r.insertBefore(s,l),e.endNodeIndex<l.length&&(n=a.createTextNode(l.data.substring(e.endNodeIndex)),r.insertBefore(n,l)),l.parentNode.removeChild(l),s}t=a.createTextNode(o.data.substring(0,e.startNodeIndex)),n=a.createTextNode(i.data.substring(e.endNodeIndex));for(var u=p(o.data.substring(e.startNodeIndex),c),d=0,f=e.innerNodes.length;d<f;++d){var g=e.innerNodes[d],h=p(g.data,c);g.parentNode.replaceChild(h,g)}var m=p(i.data.substring(0,e.endNodeIndex),c);return(r=o.parentNode).insertBefore(t,o),r.insertBefore(u,o),r.removeChild(o),(r=i.parentNode).insertBefore(m,i),r.insertBefore(n,i),r.removeChild(i),m}}(e)),this},unwrap:u,replace:function(e,t){var n=d(e);return n.deleteContents(),0<t.length&&n.insertNode(r.dom.doc.createTextNode(t)),n},rangeFromMatch:d,indexOf:s}},N=function(e,t){if(!t.get()){var n=r(e.getBody(),e);t.set(n)}return t.get()},y=function(e,t,n,r,o,i,c){var a,l,s,u=f(e);(u||(a=e,l=t,s=n,function(e,t,n,r){var o={method:e,lang:s.get()},i="";o["addToDictionary"===e?"word":"text"]=t,m.each(o,function(e,t){i&&(i+="&"),i+=t+"="+encodeURIComponent(e)}),v.send({url:new p(l).toAbsolute(d(a)),type:"post",content_type:"application/x-www-form-urlencoded",data:i,success:function(e){if(e=JSON.parse(e))e.error?r(e.error):n(e);else{var t=a.translate("Server response wasn't proper JSON.");r(t)}},error:function(){var e=a.translate("The spelling service was not found: (")+d(a)+a.translate(")");r(e)}})})).call(e.plugins.spellchecker,r,o,i,c)},S=function(e,t,n){e.dom.select("span.mce-spellchecker-word").length||w(e,t,n)},w=function(e,t,n){var r=e.selection.getBookmark();if(N(e,n).reset(),e.selection.moveToBookmark(r),n.set(null),t.get())return t.set(!1),o(e),!0},b=function(e){var t=e.getAttribute("data-mce-index");return"number"==typeof t?""+t:t},T=function(t,e,n,r,o){var i,c;if("string"!=typeof o&&o.words?(c=!!o.dictionary,i=o.words):i=o,t.setProgressState(!1),function(e){for(var t in e)return!1;return!0}(i)){var a=t.translate("No misspellings found.");return t.notificationManager.open({text:a,type:"info"}),void e.set(!1)}r.set({suggestions:i,hasDictionarySupport:c});var l=t.selection.getBookmark();N(t,n).find(s(t)).filter(function(e){return!!i[e.text]}).wrap(function(e){return t.dom.create("span",{"class":"mce-spellchecker-word","data-mce-bogus":1,"data-mce-word":e.text})}),t.selection.moveToBookmark(l),e.set(!0),u(t)},B={spellcheck:function(t,e,n,r,o,i){w(t,n,r)||(t.setProgressState(!0),y(t,e,i,"spellcheck",N(t,r).text,function(e){T(t,n,r,o,e)},function(e){t.notificationManager.open({text:e,type:"error"}),t.setProgressState(!1),w(t,n,r)}),t.focus())},checkIfFinished:S,addToDictionary:function(t,e,n,r,o,i,c){t.setProgressState(!0),y(t,e,o,"addToDictionary",i,function(){t.setProgressState(!1),t.dom.remove(c,!0),S(t,n,r)},function(e){t.notificationManager.open({text:e,type:"error"}),t.setProgressState(!1)})},ignoreWord:function(t,e,n,r,o,i){t.selection.collapse(),i?m.each(t.dom.select("span.mce-spellchecker-word"),function(e){e.getAttribute("data-mce-word")===r&&t.dom.remove(e,!0)}):t.dom.remove(o,!0),S(t,e,n)},findSpansByIndex:function(e,t){var n,r=[];if((n=m.toArray(e.getBody().getElementsByTagName("span"))).length)for(var o=0;o<n.length;o++){var i=b(n[o]);null!==i&&i.length&&i===t.toString()&&r.push(n[o])}return r},getElmIndex:b,markErrors:T},I=function(t,n,r,o,e,i){return{getTextMatcher:function(){return o.get()},getWordCharPattern:function(){return s(t)},markErrors:function(e){B.markErrors(t,n,o,r,e)},getLanguage:function(){return e.get()}}},E=function(e,t,n,r,o,i){e.addCommand("mceSpellCheck",function(){B.spellcheck(e,t,n,r,o,i)})},P=function(n,e,r,t,o,i){var c,a,l,s,u=(l=n,c=m.map(h(l).split(","),function(e){return{name:(e=e.split("="))[0],value:e[1]}}),a=[],m.each(c,function(e){a.push({selectable:!0,text:e.name,data:e.value})}),a),d=function(){B.spellcheck(n,e,r,t,i,o)},f={tooltip:"Spellcheck",onclick:d,onPostRender:function(e){var t=e.control;n.on("SpellcheckStart SpellcheckEnd",function(){t.active(r.get())})}};1<u.length&&(f.type="splitbutton",f.menu=u,f.onshow=(s=o,function(e){var t=s.get();e.control.items().each(function(e){e.active(e.settings.data===t)})}),f.onselect=function(e){o.set(e.control.settings.data)}),n.addButton("spellchecker",f),n.addMenuItem("spellchecker",{text:"Spellcheck",context:"tools",onclick:d,selectable:!0,onPostRender:function(){var e=this;e.active(r.get()),n.on("SpellcheckStart SpellcheckEnd",function(){e.active(r.get())})}})},C=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),D=tinymce.util.Tools.resolve("tinymce.ui.Factory"),R=function(o,i,c,a,l,s){o.on("click",function(e){var t=e.target;if("mce-spellchecker-word"===t.className){e.preventDefault();var n=B.findSpansByIndex(o,B.getElmIndex(t));if(0<n.length){var r=o.dom.createRng();r.setStartBefore(n[0]),r.setEndAfter(n[n.length-1]),o.selection.setRng(r),function(t,e,n,r,o,i,c,a){var l=[],s=n.get().suggestions[c];m.each(s,function(e){l.push({text:e,onclick:function(){t.insertContent(t.dom.encode(e)),t.dom.remove(a),B.checkIfFinished(t,r,o)}})}),l.push({text:"-"}),n.get().hasDictionarySupport&&l.push({text:"Add to Dictionary",onclick:function(){B.addToDictionary(t,e,r,o,i,c,a)}}),l.push.apply(l,[{text:"Ignore",onclick:function(){B.ignoreWord(t,r,o,c,a)}},{text:"Ignore all",onclick:function(){B.ignoreWord(t,r,o,c,a,!0)}}]),(k=D.create("menu",{items:l,context:"contextmenu",onautohide:function(e){-1!==e.target.className.indexOf("spellchecker")&&e.preventDefault()},onhide:function(){k.remove(),k=null}})).renderTo(g.document.body);var u=C.DOM.getPos(t.getContentAreaContainer()),d=t.dom.getPos(a[0]),f=t.dom.getRoot();"BODY"===f.nodeName?(d.x-=f.ownerDocument.documentElement.scrollLeft||f.scrollLeft,d.y-=f.ownerDocument.documentElement.scrollTop||f.scrollTop):(d.x-=f.scrollLeft,d.y-=f.scrollTop),u.x+=d.x,u.y+=d.y,k.moveTo(u.x,u.y+a[0].offsetHeight)}(o,i,c,a,l,s,t.getAttribute("data-mce-word"),n)}}})};t.add("spellchecker",function(e,t){if(!1===a(e)){var n=c(!1),r=c(l(e)),o=c(null),i=c(null);return P(e,t,n,o,r,i),R(e,t,i,n,o,r),E(e,t,n,o,i,r),I(e,n,i,o,r,t)}})}(window);
\ No newline at end of file

plugins/tabfocus/plugin.js

@@ -1,5 +1,5 @@
(function () {
-var tabfocus = (function () {
+var tabfocus = (function (domGlobals) {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
@@ -90,7 +90,7 @@
} else {
global$4.setTimeout(function () {
if (!global$3.webkit) {
- window.focus();
+ domGlobals.window.focus();
}
el.focus();
}, 10);
@@ -120,5 +120,5 @@
return Plugin;
-}());
+}(window));
})();

plugins/tabfocus/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),c=tinymce.util.Tools.resolve("tinymce.EditorManager"),s=tinymce.util.Tools.resolve("tinymce.Env"),a=tinymce.util.Tools.resolve("tinymce.util.Delay"),y=tinymce.util.Tools.resolve("tinymce.util.Tools"),f=tinymce.util.Tools.resolve("tinymce.util.VK"),d=function(e){return e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))},m=t.DOM,n=function(e){e.keyCode!==f.TAB||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()},i=function(r){function e(n){var i,o,e,l;if(!(n.keyCode!==f.TAB||n.ctrlKey||n.altKey||n.metaKey||n.isDefaultPrevented())&&(1===(e=y.explode(d(r))).length&&(e[1]=e[0],e[0]=":prev"),o=n.shiftKey?":prev"===e[0]?u(-1):m.get(e[0]):":next"===e[1]?u(1):m.get(e[1]))){var t=c.get(o.id||o.name);o.id&&t?t.focus():a.setTimeout(function(){s.webkit||window.focus(),o.focus()},10),n.preventDefault()}function u(e){function t(t){return/INPUT|TEXTAREA|BUTTON/.test(t.tagName)&&c.get(n.id)&&-1!==t.tabIndex&&function e(t){return"BODY"===t.nodeName||"hidden"!==t.type&&"none"!==t.style.display&&"hidden"!==t.style.visibility&&e(t.parentNode)}(t)}if(o=m.select(":input:enabled,*[tabindex]:not(iframe)"),y.each(o,function(e,t){if(e.id===r.id)return i=t,!1}),0<e){for(l=i+1;l<o.length;l++)if(t(o[l]))return o[l]}else for(l=i-1;0<=l;l--)if(t(o[l]))return o[l];return null}}r.on("init",function(){r.inline&&m.setAttrib(r.getBody(),"tabIndex",null),r.on("keyup",n),s.gecko?r.on("keypress keydown",e):r.on("keydown",e)})};e.add("tabfocus",function(e){i(e)})}();
\ No newline at end of file
+!function(c){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),s=tinymce.util.Tools.resolve("tinymce.EditorManager"),a=tinymce.util.Tools.resolve("tinymce.Env"),y=tinymce.util.Tools.resolve("tinymce.util.Delay"),f=tinymce.util.Tools.resolve("tinymce.util.Tools"),d=tinymce.util.Tools.resolve("tinymce.util.VK"),m=function(e){return e.getParam("tab_focus",e.getParam("tabfocus_elements",":prev,:next"))},v=t.DOM,n=function(e){e.keyCode!==d.TAB||e.ctrlKey||e.altKey||e.metaKey||e.preventDefault()},i=function(r){function e(n){var i,o,e,l;if(!(n.keyCode!==d.TAB||n.ctrlKey||n.altKey||n.metaKey||n.isDefaultPrevented())&&(1===(e=f.explode(m(r))).length&&(e[1]=e[0],e[0]=":prev"),o=n.shiftKey?":prev"===e[0]?u(-1):v.get(e[0]):":next"===e[1]?u(1):v.get(e[1]))){var t=s.get(o.id||o.name);o.id&&t?t.focus():y.setTimeout(function(){a.webkit||c.window.focus(),o.focus()},10),n.preventDefault()}function u(e){function t(t){return/INPUT|TEXTAREA|BUTTON/.test(t.tagName)&&s.get(n.id)&&-1!==t.tabIndex&&function e(t){return"BODY"===t.nodeName||"hidden"!==t.type&&"none"!==t.style.display&&"hidden"!==t.style.visibility&&e(t.parentNode)}(t)}if(o=v.select(":input:enabled,*[tabindex]:not(iframe)"),f.each(o,function(e,t){if(e.id===r.id)return i=t,!1}),0<e){for(l=i+1;l<o.length;l++)if(t(o[l]))return o[l]}else for(l=i-1;0<=l;l--)if(t(o[l]))return o[l];return null}}r.on("init",function(){r.inline&&v.setAttrib(r.getBody(),"tabIndex",null),r.on("keyup",n),a.gecko?r.on("keypress keydown",e):r.on("keydown",e)})};e.add("tabfocus",function(e){i(e)})}(window);
\ No newline at end of file

plugins/table/plugin.js

@@ -1,22 +1,22 @@
(function () {
-var table = (function () {
+var table = (function (domGlobals) {
'use strict';
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
var noop = function () {
- var x = [];
+ var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ args[_i] = arguments[_i];
}
};
var compose = function (fa, fb) {
return function () {
- var x = [];
+ var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ args[_i] = arguments[_i];
}
- return fa(fb.apply(null, arguments));
+ return fa(fb.apply(null, args));
};
};
var constant = function (value) {
@@ -27,33 +27,27 @@
var identity = function (x) {
return x;
};
- var curry = function (f) {
- var x = [];
+ function curry(fn) {
+ var initialArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
- x[_i - 1] = arguments[_i];
+ initialArgs[_i - 1] = arguments[_i];
}
- var args = new Array(arguments.length - 1);
- for (var i = 1; i < arguments.length; i++)
- args[i - 1] = arguments[i];
return function () {
- var x = [];
+ var restArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ restArgs[_i] = arguments[_i];
}
- var newArgs = new Array(arguments.length);
- for (var j = 0; j < newArgs.length; j++)
- newArgs[j] = arguments[j];
- var all = args.concat(newArgs);
- return f.apply(null, all);
- };
+ var all = initialArgs.concat(restArgs);
+ return fn.apply(null, all);
};
+ }
var not = function (f) {
return function () {
- var x = [];
+ var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
- x[_i] = arguments[_i];
+ args[_i] = arguments[_i];
}
- return !f.apply(null, arguments);
+ return !f.apply(null, args);
};
};
var die = function (msg) {
@@ -76,13 +70,13 @@
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 noop = function () {
};
var nul = function () {
return null;
@@ -98,17 +92,17 @@
isSome: never$1,
isNone: always$1,
getOr: id,
- getOrThunk: call$$1,
+ getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: nul,
getOrUndefined: undef,
or: id,
- orThunk: call$$1,
+ orThunk: call,
map: none,
ap: none,
- each: noop$$1,
+ each: noop,
bind: none,
flatten: none,
exists: never$1,
@@ -264,6 +258,29 @@
}
return r;
};
+ var groupBy = function (xs, f) {
+ if (xs.length === 0) {
+ return [];
+ } else {
+ var wasType = f(xs[0]);
+ var r = [];
+ var group = [];
+ for (var i = 0, len = xs.length; i < len; i++) {
+ var x = xs[i];
+ var type = f(x);
+ if (type !== wasType) {
+ r.push(group);
+ group = [];
+ }
+ wasType = type;
+ group.push(x);
+ }
+ if (group.length !== 0) {
+ r.push(group);
+ }
+ return r;
+ }
+ };
var foldr = function (xs, f, acc) {
eachr(xs, function (x) {
acc = f(acc, x);
@@ -331,6 +348,11 @@
r.reverse();
return r;
};
+ var sort = function (xs, comparator) {
+ var copy = slice.call(xs, 0);
+ copy.sort(comparator);
+ return copy;
+ };
var last = function (xs) {
return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]);
};
@@ -423,13 +445,13 @@
validateStrArr('optional', optional);
checkDupes(everything);
return function (obj) {
- var keys$$1 = keys(obj);
+ var keys$1 = keys(obj);
var allReqd = forall(required, function (req) {
- return contains(keys$$1, req);
+ return contains(keys$1, req);
});
if (!allReqd)
- reqMessage(required, keys$$1);
- var unsupported = filter(keys$$1, function (key) {
+ reqMessage(required, keys$1);
+ var unsupported = filter(keys$1, function (key) {
return !contains(everything, key);
});
if (unsupported.length > 0)
@@ -445,65 +467,142 @@
};
};
- var dimensions = Immutable('width', 'height');
- var grid = Immutable('rows', 'columns');
- var address = Immutable('row', 'column');
- var coords = Immutable('x', 'y');
- var detail = Immutable('element', 'rowspan', 'colspan');
- var detailnew = Immutable('element', 'rowspan', 'colspan', 'isNew');
- var extended = Immutable('element', 'rowspan', 'colspan', 'row', 'column');
- var rowdata = Immutable('element', 'cells', 'section');
- var elementnew = Immutable('element', 'isNew');
- var rowdatanew = Immutable('element', 'cells', 'section', 'isNew');
- var rowcells = Immutable('cells', 'section');
- var rowdetails = Immutable('details', 'section');
- var bounds = Immutable('startRow', 'startCol', 'finishRow', 'finishCol');
- var Structs = {
- dimensions: dimensions,
- grid: grid,
- address: address,
- coords: coords,
- extended: extended,
- detail: detail,
- detailnew: detailnew,
- rowdata: rowdata,
- elementnew: elementnew,
- rowdatanew: rowdatanew,
- rowcells: rowcells,
- rowdetails: rowdetails,
- bounds: bounds
+ var ATTRIBUTE = domGlobals.Node.ATTRIBUTE_NODE;
+ var CDATA_SECTION = domGlobals.Node.CDATA_SECTION_NODE;
+ var COMMENT = domGlobals.Node.COMMENT_NODE;
+ var DOCUMENT = domGlobals.Node.DOCUMENT_NODE;
+ var DOCUMENT_TYPE = domGlobals.Node.DOCUMENT_TYPE_NODE;
+ var DOCUMENT_FRAGMENT = domGlobals.Node.DOCUMENT_FRAGMENT_NODE;
+ var ELEMENT = domGlobals.Node.ELEMENT_NODE;
+ var TEXT = domGlobals.Node.TEXT_NODE;
+ var PROCESSING_INSTRUCTION = domGlobals.Node.PROCESSING_INSTRUCTION_NODE;
+ var ENTITY_REFERENCE = domGlobals.Node.ENTITY_REFERENCE_NODE;
+ var ENTITY = domGlobals.Node.ENTITY_NODE;
+ var NOTATION = domGlobals.Node.NOTATION_NODE;
+
+ var name = function (element) {
+ var r = element.dom().nodeName;
+ return r.toLowerCase();
+ };
+ var type = function (element) {
+ return element.dom().nodeType;
+ };
+ var isType$1 = function (t) {
+ return function (element) {
+ return type(element) === t;
+ };
+ };
+ var isComment = function (element) {
+ return type(element) === COMMENT || name(element) === '#comment';
+ };
+ var isElement = isType$1(ELEMENT);
+ var isText = isType$1(TEXT);
+ var isDocument = isType$1(DOCUMENT);
+
+ var rawSet = function (dom, key, value) {
+ if (isString(value) || isBoolean(value) || isNumber(value)) {
+ dom.setAttribute(key, value + '');
+ } else {
+ domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
+ throw new Error('Attribute value was not simple');
+ }
+ };
+ var set = function (element, key, value) {
+ rawSet(element.dom(), key, value);
+ };
+ var setAll = function (element, attrs) {
+ var dom = element.dom();
+ each$1(attrs, function (v, k) {
+ rawSet(dom, k, v);
+ });
+ };
+ var get = function (element, key) {
+ var v = element.dom().getAttribute(key);
+ return v === null ? undefined : v;
+ };
+ var has = function (element, key) {
+ var dom = element.dom();
+ return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
+ };
+ var remove = function (element, key) {
+ element.dom().removeAttribute(key);
+ };
+ var clone = function (element) {
+ return foldl(element.dom().attributes, function (acc, attr) {
+ acc[attr.name] = attr.value;
+ return acc;
+ }, {});
+ };
+
+ var checkRange = function (str, substr, start) {
+ if (substr === '')
+ return true;
+ if (str.length < substr.length)
+ return false;
+ var x = str.substr(start, start + substr.length);
+ return x === substr;
+ };
+ var contains$1 = function (str, substr) {
+ return str.indexOf(substr) !== -1;
+ };
+ var endsWith = function (str, suffix) {
+ return checkRange(str, suffix, str.length - suffix.length);
+ };
+ var trim = function (str) {
+ return str.replace(/^\s+|\s+$/g, '');
+ };
+
+ var isSupported = function (dom) {
+ return dom.style !== undefined;
+ };
+
+ var cached = function (f) {
+ var called = false;
+ var r;
+ return function () {
+ var args = [];
+ for (var _i = 0; _i < arguments.length; _i++) {
+ args[_i] = arguments[_i];
+ }
+ if (!called) {
+ called = true;
+ r = f.apply(null, args);
+ }
+ return r;
+ };
};
var fromHtml = function (html, scope) {
- var doc = scope || document;
+ var doc = scope || domGlobals.document;
var div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
- console.error('HTML does not have a single root node', html);
- throw 'HTML must have a single root node';
+ domGlobals.console.error('HTML does not have a single root node', html);
+ throw new Error('HTML must have a single root node');
}
return fromDom(div.childNodes[0]);
};
var fromTag = function (tag, scope) {
- var doc = scope || document;
+ var doc = scope || domGlobals.document;
var node = doc.createElement(tag);
return fromDom(node);
};
var fromText = function (text, scope) {
- var doc = scope || document;
+ var doc = scope || domGlobals.document;
var node = doc.createTextNode(text);
return fromDom(node);
};
var fromDom = function (node) {
- if (node === null || node === undefined)
+ if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
+ }
return { dom: constant(node) };
};
var fromPoint = function (docElm, x, y) {
var doc = docElm.dom();
return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
};
- var Element$$1 = {
+ var Element = {
fromHtml: fromHtml,
fromTag: fromTag,
fromText: fromText,
@@ -511,49 +610,78 @@
fromPoint: fromPoint
};
- var ATTRIBUTE = Node.ATTRIBUTE_NODE;
- var CDATA_SECTION = Node.CDATA_SECTION_NODE;
- var COMMENT = Node.COMMENT_NODE;
- var DOCUMENT = Node.DOCUMENT_NODE;
- var DOCUMENT_TYPE = Node.DOCUMENT_TYPE_NODE;
- var DOCUMENT_FRAGMENT = Node.DOCUMENT_FRAGMENT_NODE;
- var ELEMENT = Node.ELEMENT_NODE;
- var TEXT = Node.TEXT_NODE;
- var PROCESSING_INSTRUCTION = Node.PROCESSING_INSTRUCTION_NODE;
- var ENTITY_REFERENCE = Node.ENTITY_REFERENCE_NODE;
- var ENTITY = Node.ENTITY_NODE;
- var NOTATION = Node.NOTATION_NODE;
+ var inBody = function (element) {
+ var dom = isText(element) ? element.dom().parentNode : element.dom();
+ return dom !== undefined && dom !== null && dom.ownerDocument.body.contains(dom);
+ };
+ var body = cached(function () {
+ return getBody(Element.fromDom(domGlobals.document));
+ });
+ var getBody = function (doc) {
+ var b = doc.dom().body;
+ if (b === null || b === undefined) {
+ throw new Error('Body is not available yet');
+ }
+ return Element.fromDom(b);
+ };
- var ELEMENT$1 = ELEMENT;
- var DOCUMENT$1 = DOCUMENT;
- var is = function (element, selector) {
- var elem = element.dom();
- if (elem.nodeType !== ELEMENT$1)
- return false;
- else if (elem.matches !== undefined)
- return elem.matches(selector);
- else if (elem.msMatchesSelector !== undefined)
- return elem.msMatchesSelector(selector);
- else if (elem.webkitMatchesSelector !== undefined)
- return elem.webkitMatchesSelector(selector);
- else if (elem.mozMatchesSelector !== undefined)
- return elem.mozMatchesSelector(selector);
- else
- throw new Error('Browser lacks native selectors');
+ var internalSet = function (dom, property, value) {
+ if (!isString(value)) {
+ domGlobals.console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
+ throw new Error('CSS value must be a string: ' + value);
+ }
+ if (isSupported(dom)) {
+ dom.style.setProperty(property, value);
+ }
};
- var bypassSelector = function (dom) {
- return dom.nodeType !== ELEMENT$1 && dom.nodeType !== DOCUMENT$1 || dom.childElementCount === 0;
+ var internalRemove = function (dom, property) {
+ if (isSupported(dom)) {
+ dom.style.removeProperty(property);
+ }
};
- var all = function (selector, scope) {
- var base = scope === undefined ? document : scope.dom();
- return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element$$1.fromDom);
+ var set$1 = function (element, property, value) {
+ var dom = element.dom();
+ internalSet(dom, property, value);
};
- var one = function (selector, scope) {
- var base = scope === undefined ? document : scope.dom();
- return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element$$1.fromDom);
+ var setAll$1 = function (element, css) {
+ var dom = element.dom();
+ each$1(css, function (v, k) {
+ internalSet(dom, k, v);
+ });
+ };
+ var get$1 = function (element, property) {
+ var dom = element.dom();
+ var styles = domGlobals.window.getComputedStyle(dom);
+ var r = styles.getPropertyValue(property);
+ var v = r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
+ return v === null ? undefined : v;
+ };
+ var getUnsafeProperty = function (dom, property) {
+ return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
+ };
+ var getRaw = function (element, property) {
+ var dom = element.dom();
+ var raw = getUnsafeProperty(dom, property);
+ return Option.from(raw).filter(function (r) {
+ return r.length > 0;
+ });
+ };
+ var remove$1 = function (element, property) {
+ var dom = element.dom();
+ internalRemove(dom, property);
+ if (has(element, 'style') && trim(get(element, 'style')) === '') {
+ remove(element, 'style');
+ }
+ };
+ var copy = function (source, target) {
+ var sourceDom = source.dom();
+ var targetDom = target.dom();
+ if (isSupported(sourceDom) && isSupported(targetDom)) {
+ targetDom.style.cssText = sourceDom.style.cssText;
+ }
};
- 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;
@@ -590,27 +718,11 @@
var documentPositionContainedBy = function (a, b) {
return compareDocumentPosition(a, b, node().DOCUMENT_POSITION_CONTAINED_BY);
};
- var Node$1 = {
+ var Node = {
documentPositionPreceding: documentPositionPreceding,
documentPositionContainedBy: documentPositionContainedBy
};
- var cached = function (f) {
- var called = false;
- var r;
- return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- if (!called) {
- called = true;
- r = f.apply(null, args);
- }
- return r;
- };
- };
-
var firstMatch = function (regexes, s) {
for (var i = 0; i < regexes.length; i++) {
var x = regexes[i];
@@ -619,7 +731,7 @@
}
return undefined;
};
- var find$2 = function (regexes, agent) {
+ var find$1 = function (regexes, agent) {
var r = firstMatch(regexes, agent);
if (!r)
return {
@@ -635,7 +747,7 @@
var cleanedAgent = String(agent).toLowerCase();
if (versionRegexes.length === 0)
return unknown();
- return find$2(versionRegexes, cleanedAgent);
+ return find$1(versionRegexes, cleanedAgent);
};
var unknown = function () {
return nu(0, 0);
@@ -789,24 +901,6 @@
detectOs: detectOs
};
- var checkRange = function (str, substr, start) {
- if (substr === '')
- return true;
- if (str.length < substr.length)
- return false;
- var x = str.substr(start, start + substr.length);
- return x === substr;
- };
- var contains$1 = function (str, substr) {
- return str.indexOf(substr) !== -1;
- };
- var endsWith = function (str, suffix) {
- return checkRange(str, suffix, str.length - suffix.length);
- };
- var trim = function (str) {
- return str.replace(/^\s+|\s+$/g, '');
- };
-
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
var checkContains = function (target) {
return function (uastring) {
@@ -929,36 +1023,67 @@
var PlatformDetection = { detect: detect$2 };
var detect$3 = cached(function () {
- var userAgent = navigator.userAgent;
+ var userAgent = domGlobals.navigator.userAgent;
return PlatformDetection.detect(userAgent);
});
var PlatformDetection$1 = { detect: detect$3 };
+ var ELEMENT$1 = ELEMENT;
+ var DOCUMENT$1 = DOCUMENT;
+ var is = function (element, selector) {
+ var elem = element.dom();
+ if (elem.nodeType !== ELEMENT$1) {
+ return false;
+ } else if (elem.matches !== undefined) {
+ return elem.matches(selector);
+ } else if (elem.msMatchesSelector !== undefined) {
+ return elem.msMatchesSelector(selector);
+ } else if (elem.webkitMatchesSelector !== undefined) {
+ return elem.webkitMatchesSelector(selector);
+ } else if (elem.mozMatchesSelector !== undefined) {
+ return elem.mozMatchesSelector(selector);
+ } else {
+ throw new Error('Browser lacks native selectors');
+ }
+ };
+ var bypassSelector = function (dom) {
+ return dom.nodeType !== ELEMENT$1 && dom.nodeType !== DOCUMENT$1 || dom.childElementCount === 0;
+ };
+ var all = function (selector, scope) {
+ var base = scope === undefined ? domGlobals.document : scope.dom();
+ return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element.fromDom);
+ };
+ var one = function (selector, scope) {
+ var base = scope === undefined ? domGlobals.document : scope.dom();
+ return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element.fromDom);
+ };
+
var eq = function (e1, e2) {
return e1.dom() === e2.dom();
};
var regularContains = function (e1, e2) {
- var d1 = e1.dom(), d2 = e2.dom();
+ var d1 = e1.dom();
+ var d2 = e2.dom();
return d1 === d2 ? false : d1.contains(d2);
};
var ieContains = function (e1, e2) {
- return Node$1.documentPositionContainedBy(e1.dom(), e2.dom());
+ return Node.documentPositionContainedBy(e1.dom(), e2.dom());
};
var browser = PlatformDetection$1.detect().browser;
var contains$2 = browser.isIE() ? ieContains : regularContains;
var is$1 = is;
var owner = function (element) {
- return Element$$1.fromDom(element.dom().ownerDocument);
+ return Element.fromDom(element.dom().ownerDocument);
};
var defaultView = function (element) {
var el = element.dom();
- var defaultView = el.ownerDocument.defaultView;
- return Element$$1.fromDom(defaultView);
+ var defView = el.ownerDocument.defaultView;
+ return Element.fromDom(defView);
};
var parent = function (element) {
var dom = element.dom();
- return Option.from(dom.parentNode).map(Element$$1.fromDom);
+ return Option.from(dom.parentNode).map(Element.fromDom);
};
var parents = function (element, isRoot) {
var stop = isFunction(isRoot) ? isRoot : constant(false);
@@ -966,115 +1091,134 @@
var ret = [];
while (dom.parentNode !== null && dom.parentNode !== undefined) {
var rawParent = dom.parentNode;
- var parent = Element$$1.fromDom(rawParent);
- ret.push(parent);
- if (stop(parent) === true)
+ var p = Element.fromDom(rawParent);
+ ret.push(p);
+ if (stop(p) === true) {
break;
- else
+ } else {
dom = rawParent;
}
+ }
return ret;
};
var prevSibling = function (element) {
var dom = element.dom();
- return Option.from(dom.previousSibling).map(Element$$1.fromDom);
+ return Option.from(dom.previousSibling).map(Element.fromDom);
};
var nextSibling = function (element) {
var dom = element.dom();
- return Option.from(dom.nextSibling).map(Element$$1.fromDom);
+ return Option.from(dom.nextSibling).map(Element.fromDom);
};
var children = function (element) {
var dom = element.dom();
- return map(dom.childNodes, Element$$1.fromDom);
+ return map(dom.childNodes, Element.fromDom);
};
var child = function (element, index) {
- var children = element.dom().childNodes;
- return Option.from(children[index]).map(Element$$1.fromDom);
+ var cs = element.dom().childNodes;
+ return Option.from(cs[index]).map(Element.fromDom);
};
var firstChild = function (element) {
return child(element, 0);
};
var spot = Immutable('element', 'offset');
- var firstLayer = function (scope, selector) {
- return filterFirstLayer(scope, selector, constant(true));
- };
- var filterFirstLayer = function (scope, selector, predicate) {
- return bind(children(scope), function (x) {
- return is(x, selector) ? predicate(x) ? [x] : [] : filterFirstLayer(x, selector, predicate);
+ var before = function (marker, element) {
+ var parent$1 = parent(marker);
+ parent$1.each(function (v) {
+ v.dom().insertBefore(element.dom(), marker.dom());
});
};
- var LayerSelector = {
- firstLayer: firstLayer,
- filterFirstLayer: filterFirstLayer
- };
-
- var name = function (element) {
- var r = element.dom().nodeName;
- return r.toLowerCase();
- };
- var type = function (element) {
- return element.dom().nodeType;
+ var after = function (marker, element) {
+ var sibling = nextSibling(marker);
+ sibling.fold(function () {
+ var parent$1 = parent(marker);
+ parent$1.each(function (v) {
+ append(v, element);
+ });
+ }, function (v) {
+ before(v, element);
+ });
};
- var isType$1 = function (t) {
- return function (element) {
- return type(element) === t;
+ var prepend = function (parent, element) {
+ var firstChild$1 = firstChild(parent);
+ firstChild$1.fold(function () {
+ append(parent, element);
+ }, function (v) {
+ parent.dom().insertBefore(element.dom(), v.dom());
+ });
};
+ var append = function (parent, element) {
+ parent.dom().appendChild(element.dom());
};
- var isComment = function (element) {
- return type(element) === COMMENT || name(element) === '#comment';
+ var wrap = function (element, wrapper) {
+ before(element, wrapper);
+ append(wrapper, element);
};
- var isElement = isType$1(ELEMENT);
- var isText = isType$1(TEXT);
- var isDocument = isType$1(DOCUMENT);
- var rawSet = function (dom, key, value$$1) {
- if (isString(value$$1) || isBoolean(value$$1) || isNumber(value$$1)) {
- dom.setAttribute(key, value$$1 + '');
- } else {
- console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value$$1, ':: Element ', dom);
- throw new Error('Attribute value was not simple');
- }
+ var before$1 = function (marker, elements) {
+ each(elements, function (x) {
+ before(marker, x);
+ });
};
- var set = function (element, key, value$$1) {
- rawSet(element.dom(), key, value$$1);
+ var after$1 = function (marker, elements) {
+ each(elements, function (x, i) {
+ var e = i === 0 ? marker : elements[i - 1];
+ after(e, x);
+ });
};
- var setAll = function (element, attrs) {
- var dom = element.dom();
- each$1(attrs, function (v, k) {
- rawSet(dom, k, v);
+ var append$1 = function (parent, elements) {
+ each(elements, function (x) {
+ append(parent, x);
});
};
- var get$1 = function (element, key) {
- var v = element.dom().getAttribute(key);
- return v === null ? undefined : v;
+
+ var empty = function (element) {
+ element.dom().textContent = '';
+ each(children(element), function (rogue) {
+ remove$2(rogue);
+ });
};
- var has$1 = function (element, key) {
+ var remove$2 = function (element) {
var dom = element.dom();
- return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
- };
- var remove = function (element, key) {
- element.dom().removeAttribute(key);
+ if (dom.parentNode !== null) {
+ dom.parentNode.removeChild(dom);
+ }
};
- var clone = function (element) {
- return foldl(element.dom().attributes, function (acc, attr) {
- acc[attr.name] = attr.value;
- return acc;
- }, {});
+ var unwrap = function (wrapper) {
+ var children$1 = children(wrapper);
+ if (children$1.length > 0) {
+ before$1(wrapper, children$1);
+ }
+ remove$2(wrapper);
};
- var inBody = function (element) {
- var dom = isText(element) ? element.dom().parentNode : element.dom();
- return dom !== undefined && dom !== null && dom.ownerDocument.body.contains(dom);
- };
- var body = cached(function () {
- return getBody(Element$$1.fromDom(document));
- });
- var getBody = function (doc) {
- var body = doc.dom().body;
- if (body === null || body === undefined)
- throw 'Body is not available yet';
- return Element$$1.fromDom(body);
+ var dimensions = Immutable('width', 'height');
+ var grid = Immutable('rows', 'columns');
+ var address = Immutable('row', 'column');
+ var coords = Immutable('x', 'y');
+ var detail = Immutable('element', 'rowspan', 'colspan');
+ var detailnew = Immutable('element', 'rowspan', 'colspan', 'isNew');
+ var extended = Immutable('element', 'rowspan', 'colspan', 'row', 'column');
+ var rowdata = Immutable('element', 'cells', 'section');
+ var elementnew = Immutable('element', 'isNew');
+ var rowdatanew = Immutable('element', 'cells', 'section', 'isNew');
+ var rowcells = Immutable('cells', 'section');
+ var rowdetails = Immutable('details', 'section');
+ var bounds = Immutable('startRow', 'startCol', 'finishRow', 'finishCol');
+ var Structs = {
+ dimensions: dimensions,
+ grid: grid,
+ address: address,
+ coords: coords,
+ extended: extended,
+ detail: detail,
+ detailnew: detailnew,
+ rowdata: rowdata,
+ elementnew: elementnew,
+ rowdatanew: rowdatanew,
+ rowcells: rowcells,
+ rowdetails: rowdetails,
+ bounds: bounds
};
var ancestors = function (scope, predicate, isRoot) {
@@ -1117,33 +1261,36 @@
var stop = isFunction(isRoot) ? isRoot : constant(false);
while (element.parentNode) {
element = element.parentNode;
- var el = Element$$1.fromDom(element);
- if (predicate(el))
+ var el = Element.fromDom(element);
+ if (predicate(el)) {
return Option.some(el);
- else if (stop(el))
+ } else if (stop(el)) {
break;
}
+ }
return Option.none();
};
var closest = function (scope, predicate, isRoot) {
- var is = function (scope) {
- return predicate(scope);
+ var is = function (s) {
+ return predicate(s);
};
return ClosestOrAncestor(is, ancestor, scope, predicate, isRoot);
};
var child$1 = function (scope, predicate) {
- var result = find(scope.dom().childNodes, compose(predicate, Element$$1.fromDom));
- return result.map(Element$$1.fromDom);
+ var result = find(scope.dom().childNodes, compose(predicate, Element.fromDom));
+ return result.map(Element.fromDom);
};
var descendant = function (scope, predicate) {
var descend = function (node) {
for (var i = 0; i < node.childNodes.length; i++) {
- if (predicate(Element$$1.fromDom(node.childNodes[i])))
- return Option.some(Element$$1.fromDom(node.childNodes[i]));
+ if (predicate(Element.fromDom(node.childNodes[i]))) {
+ return Option.some(Element.fromDom(node.childNodes[i]));
+ }
var res = descend(node.childNodes[i]);
- if (res.isSome())
+ if (res.isSome()) {
return res;
}
+ }
return Option.none();
};
return descend(scope.dom());
@@ -1166,14 +1313,29 @@
return ClosestOrAncestor(is, ancestor$1, scope, selector, isRoot);
};
+ var firstLayer = function (scope, selector) {
+ return filterFirstLayer(scope, selector, constant(true));
+ };
+ var filterFirstLayer = function (scope, selector, predicate) {
+ return bind(children(scope), function (x) {
+ return is(x, selector) ? predicate(x) ? [x] : [] : filterFirstLayer(x, selector, predicate);
+ });
+ };
+ var LayerSelector = {
+ firstLayer: firstLayer,
+ filterFirstLayer: filterFirstLayer
+ };
+
var lookup = function (tags, element, _isRoot) {
var isRoot = _isRoot !== undefined ? _isRoot : constant(false);
- if (isRoot(element))
+ if (isRoot(element)) {
return Option.none();
- if (contains(tags, name(element)))
+ }
+ if (contains(tags, name(element))) {
return Option.some(element);
- var isRootOrUpperTable = function (element) {
- return is(element, 'table') || isRoot(element);
+ }
+ var isRootOrUpperTable = function (elm) {
+ return is(elm, 'table') || isRoot(elm);
};
return ancestor$1(element, tags.join(','), isRootOrUpperTable);
};
@@ -1196,8 +1358,8 @@
], element, isRoot);
};
var neighbours = function (selector, element) {
- return parent(element).map(function (parent$$1) {
- return children$2(parent$$1, selector);
+ return parent(element).map(function (parent) {
+ return children$2(parent, selector);
});
};
var neighbourCells = curry(neighbours, 'th,td');
@@ -1215,12 +1377,12 @@
return LayerSelector.firstLayer(ancestor, 'tr');
};
var attr = function (element, property) {
- return parseInt(get$1(element, property), 10);
+ return parseInt(get(element, property), 10);
};
var grid$1 = function (element, rowProp, colProp) {
- var rows = attr(element, rowProp);
+ var rowsCount = attr(element, rowProp);
var cols = attr(element, colProp);
- return Structs.grid(rows, cols);
+ return Structs.grid(rowsCount, cols);
};
var TableLookup = {
cell: cell,
@@ -1240,14 +1402,14 @@
var rows = TableLookup.rows(table);
return map(rows, function (row) {
var element = row;
- var parent$$1 = parent(element);
- var parentSection = parent$$1.map(function (parent$$1) {
- var parentName = name(parent$$1);
+ var parent$1 = parent(element);
+ var parentSection = parent$1.map(function (p) {
+ var parentName = name(p);
return parentName === 'tfoot' || parentName === 'thead' || parentName === 'tbody' ? parentName : 'tbody';
}).getOr('tbody');
var cells = map(TableLookup.cells(row), function (cell) {
- var rowspan = has$1(cell, 'rowspan') ? parseInt(get$1(cell, 'rowspan'), 10) : 1;
- var colspan = has$1(cell, 'colspan') ? parseInt(get$1(cell, 'colspan'), 10) : 1;
+ var rowspan = has(cell, 'rowspan') ? parseInt(get(cell, 'rowspan'), 10) : 1;
+ var colspan = has(cell, 'colspan') ? parseInt(get(cell, 'colspan'), 10) : 1;
return Structs.detail(cell, rowspan, colspan);
});
return Structs.rowdata(element, cells, parentSection);
@@ -1256,8 +1418,8 @@
var fromPastedRows = function (rows, example) {
return map(rows, function (row) {
var cells = map(TableLookup.cells(row), function (cell) {
- var rowspan = has$1(cell, 'rowspan') ? parseInt(get$1(cell, 'rowspan'), 10) : 1;
- var colspan = has$1(cell, 'colspan') ? parseInt(get$1(cell, 'colspan'), 10) : 1;
+ var rowspan = has(cell, 'rowspan') ? parseInt(get(cell, 'rowspan'), 10) : 1;
+ var colspan = has(cell, 'colspan') ? parseInt(get(cell, 'colspan'), 10) : 1;
return Structs.detail(cell, rowspan, colspan);
});
return Structs.rowdata(row, cells, example.section());
@@ -1334,133 +1496,7 @@
justCells: justCells
};
- var isSupported = function (dom) {
- return dom.style !== undefined;
- };
-
- var internalSet = function (dom, property, value$$1) {
- if (!isString(value$$1)) {
- console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value$$1, ':: Element ', dom);
- throw new Error('CSS value must be a string: ' + value$$1);
- }
- if (isSupported(dom))
- dom.style.setProperty(property, value$$1);
- };
- var internalRemove = function (dom, property) {
- if (isSupported(dom))
- dom.style.removeProperty(property);
- };
- var set$1 = function (element, property, value$$1) {
- var dom = element.dom();
- internalSet(dom, property, value$$1);
- };
- var setAll$1 = function (element, css) {
- var dom = element.dom();
- each$1(css, function (v, k) {
- internalSet(dom, k, v);
- });
- };
- var get$2 = function (element, property) {
- var dom = element.dom();
- var styles = window.getComputedStyle(dom);
- var r = styles.getPropertyValue(property);
- var v = r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
- return v === null ? undefined : v;
- };
- var getUnsafeProperty = function (dom, property) {
- return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
- };
- var getRaw = function (element, property) {
- var dom = element.dom();
- var raw = getUnsafeProperty(dom, property);
- return Option.from(raw).filter(function (r) {
- return r.length > 0;
- });
- };
- var remove$1 = function (element, property) {
- var dom = element.dom();
- internalRemove(dom, property);
- if (has$1(element, 'style') && trim(get$1(element, 'style')) === '') {
- remove(element, 'style');
- }
- };
- var copy = function (source, target) {
- var sourceDom = source.dom();
- var targetDom = target.dom();
- if (isSupported(sourceDom) && isSupported(targetDom)) {
- targetDom.style.cssText = sourceDom.style.cssText;
- }
- };
-
- var before = function (marker, element) {
- var parent$$1 = parent(marker);
- parent$$1.each(function (v) {
- v.dom().insertBefore(element.dom(), marker.dom());
- });
- };
- var after = function (marker, element) {
- var sibling = nextSibling(marker);
- sibling.fold(function () {
- var parent$$1 = parent(marker);
- parent$$1.each(function (v) {
- append(v, element);
- });
- }, function (v) {
- before(v, element);
- });
- };
- var prepend = function (parent$$1, element) {
- var firstChild$$1 = firstChild(parent$$1);
- firstChild$$1.fold(function () {
- append(parent$$1, element);
- }, function (v) {
- parent$$1.dom().insertBefore(element.dom(), v.dom());
- });
- };
- var append = function (parent$$1, element) {
- parent$$1.dom().appendChild(element.dom());
- };
- var wrap = function (element, wrapper) {
- before(element, wrapper);
- append(wrapper, element);
- };
-
- var before$1 = function (marker, elements) {
- each(elements, function (x) {
- before(marker, x);
- });
- };
- var after$1 = function (marker, elements) {
- each(elements, function (x, i) {
- var e = i === 0 ? marker : elements[i - 1];
- after(e, x);
- });
- };
- var append$1 = function (parent, elements) {
- each(elements, function (x) {
- append(parent, x);
- });
- };
-
- var empty = function (element) {
- element.dom().textContent = '';
- each(children(element), function (rogue) {
- remove$2(rogue);
- });
- };
- var remove$2 = function (element) {
- var dom = element.dom();
- if (dom.parentNode !== null)
- dom.parentNode.removeChild(dom);
- };
- var unwrap = function (wrapper) {
- var children$$1 = children(wrapper);
- if (children$$1.length > 0)
- before$1(wrapper, children$$1);
- remove$2(wrapper);
- };
-
- var stats = Immutable('minRow', 'minCol', 'maxRow', 'maxCol');
+ var statsStruct = Immutable('minRow', 'minCol', 'maxRow', 'maxCol');
var findSelectedStats = function (house, isSelected) {
var totalColumns = house.grid().columns();
var totalRows = house.grid().rows();
@@ -1474,22 +1510,24 @@
var endRow = startRow + detail.rowspan() - 1;
var startCol = detail.column();
var endCol = startCol + detail.colspan() - 1;
- if (startRow < minRow)
+ if (startRow < minRow) {
minRow = startRow;
- else if (endRow > maxRow)
+ } else if (endRow > maxRow) {
maxRow = endRow;
- if (startCol < minCol)
+ }
+ if (startCol < minCol) {
minCol = startCol;
- else if (endCol > maxCol)
+ } else if (endCol > maxCol) {
maxCol = endCol;
}
+ }
});
- return stats(minRow, minCol, maxRow, maxCol);
+ return statsStruct(minRow, minCol, maxRow, maxCol);
};
var makeCell = function (list, seenSelected, rowIndex) {
var row = list[rowIndex].element();
- var td = Element$$1.fromTag('td');
- append(td, Element$$1.fromTag('br'));
+ var td = Element.fromTag('td');
+ append(td, Element.fromTag('br'));
var f = seenSelected ? append : prepend;
f(row, td);
};
@@ -1501,13 +1539,14 @@
for (var j = 0; j < totalColumns; j++) {
if (!(i < stats.minRow() || i > stats.maxRow() || j < stats.minCol() || j > stats.maxCol())) {
var needCell = Warehouse.getAt(house, i, j).filter(isSelected).isNone();
- if (needCell)
+ if (needCell) {
makeCell(list, seenSelected, i);
- else
+ } else {
seenSelected = true;
}
}
}
+ }
};
var clean = function (table, stats) {
var emptyRows = filter(LayerSelector.firstLayer(table, 'tr'), function (row) {
@@ -1543,32 +1582,11 @@
};
var CopySelected = { extract: extract };
- var clone$1 = function (original, deep) {
- return Element$$1.fromDom(original.dom().cloneNode(deep));
- };
- var shallow = function (original) {
- return clone$1(original, false);
- };
- var deep = function (original) {
- return clone$1(original, true);
- };
- var shallowAs = function (original, tag) {
- var nu = Element$$1.fromTag(tag);
- var attributes = clone(original);
- setAll(nu, attributes);
- return nu;
- };
- var copy$1 = function (original, tag) {
- var nu = shallowAs(original, tag);
- var cloneChildren = children(deep(original));
- append$1(nu, cloneChildren);
- return nu;
- };
-
function NodeValue (is, name) {
var get = function (element) {
- if (!is(element))
+ if (!is(element)) {
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
+ }
return getOption(element).getOr('');
};
var getOptionIE10 = function (element) {
@@ -1584,8 +1602,9 @@
var browser = PlatformDetection$1.detect().browser;
var getOption = browser.isIE() && browser.version.major === 10 ? getOptionIE10 : getOptionSafe;
var set = function (element, value) {
- if (!is(element))
+ if (!is(element)) {
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
+ }
element.dom().nodeValue = value;
};
return {
@@ -1596,14 +1615,14 @@
}
var api = NodeValue(isText, 'text');
- var get$3 = function (element) {
+ var get$2 = function (element) {
return api.get(element);
};
var getOption = function (element) {
return api.getOption(element);
};
- var set$2 = function (element, value$$1) {
- api.set(element, value$$1);
+ var set$2 = function (element, value) {
+ api.set(element, value);
};
var getEnd = function (element) {
@@ -1628,40 +1647,65 @@
return hasCursorPosition || contains(elementsWithCursorPosition, name(elem));
};
- var first$3 = function (element) {
+ var first = function (element) {
return descendant(element, isCursorPosition);
};
- var last$2 = function (element) {
+ var last$1 = function (element) {
return descendantRtl(element, isCursorPosition);
};
var descendantRtl = function (scope, predicate) {
var descend = function (element) {
- var children$$1 = children(element);
- for (var i = children$$1.length - 1; i >= 0; i--) {
- var child$$1 = children$$1[i];
- if (predicate(child$$1))
- return Option.some(child$$1);
- var res = descend(child$$1);
- if (res.isSome())
+ var children$1 = children(element);
+ for (var i = children$1.length - 1; i >= 0; i--) {
+ var child = children$1[i];
+ if (predicate(child)) {
+ return Option.some(child);
+ }
+ var res = descend(child);
+ if (res.isSome()) {
return res;
}
+ }
return Option.none();
};
return descend(scope);
};
- var cell$1 = function () {
- var td = Element$$1.fromTag('td');
- append(td, Element$$1.fromTag('br'));
+ var clone$1 = function (original, isDeep) {
+ return Element.fromDom(original.dom().cloneNode(isDeep));
+ };
+ var shallow = function (original) {
+ return clone$1(original, false);
+ };
+ var deep = function (original) {
+ return clone$1(original, true);
+ };
+ var shallowAs = function (original, tag) {
+ var nu = Element.fromTag(tag);
+ var attributes = clone(original);
+ setAll(nu, attributes);
+ return nu;
+ };
+ var copy$1 = function (original, tag) {
+ var nu = shallowAs(original, tag);
+ var cloneChildren = children(deep(original));
+ append$1(nu, cloneChildren);
+ return nu;
+ };
+
+ var createCell = function () {
+ var td = Element.fromTag('td');
+ append(td, Element.fromTag('br'));
return td;
};
var replace = function (cell, tag, attrs) {
var replica = copy$1(cell, tag);
each$1(attrs, function (v, k) {
- if (v === null)
+ if (v === null) {
remove(replica, k);
- else
+ } else {
set(replica, k, v);
+ }
});
return replica;
};
@@ -1670,28 +1714,28 @@
};
var newRow = function (doc) {
return function () {
- return Element$$1.fromTag('tr', doc.dom());
+ return Element.fromTag('tr', doc.dom());
};
};
var cloneFormats = function (oldCell, newCell, formats) {
- var first = first$3(oldCell);
- return first.map(function (firstText) {
+ var first$1 = first(oldCell);
+ return first$1.map(function (firstText) {
var formatSelector = formats.join(',');
- var parents$$1 = ancestors$1(firstText, formatSelector, function (element) {
+ var parents = ancestors$1(firstText, formatSelector, function (element) {
return eq(element, oldCell);
});
- return foldr(parents$$1, function (last$$1, parent$$1) {
- var clonedFormat = shallow(parent$$1);
+ return foldr(parents, function (last, parent) {
+ var clonedFormat = shallow(parent);
remove(clonedFormat, 'contenteditable');
- append(last$$1, clonedFormat);
+ append(last, clonedFormat);
return clonedFormat;
}, newCell);
}).getOr(newCell);
};
- var cellOperations = function (mutate$$1, doc, formatsToClone) {
+ var cellOperations = function (mutate, doc, formatsToClone) {
var newCell = function (prev) {
- var doc = owner(prev.element());
- var td = Element$$1.fromTag(name(prev.element()), doc.dom());
+ var docu = owner(prev.element());
+ var td = Element.fromTag(name(prev.element()), docu.dom());
var formats = formatsToClone.getOr([
'strong',
'em',
@@ -1709,27 +1753,28 @@
'div'
]);
var lastNode = formats.length > 0 ? cloneFormats(prev.element(), td, formats) : td;
- append(lastNode, Element$$1.fromTag('br'));
+ append(lastNode, Element.fromTag('br'));
copy(prev.element(), td);
remove$1(td, 'height');
- if (prev.colspan() !== 1)
+ if (prev.colspan() !== 1) {
remove$1(prev.element(), 'width');
- mutate$$1(prev.element(), td);
+ }
+ mutate(prev.element(), td);
return td;
};
return {
row: newRow(doc),
cell: newCell,
replace: replace,
- gap: cell$1
+ gap: createCell
};
};
var paste = function (doc) {
return {
row: newRow(doc),
- cell: cell$1,
+ cell: createCell,
replace: pasteReplace,
- gap: cell$1
+ gap: createCell
};
};
var TableFill = {
@@ -1738,10 +1783,10 @@
};
var fromHtml$1 = function (html, scope) {
- var doc = scope || document;
+ var doc = scope || domGlobals.document;
var div = doc.createElement('div');
div.innerHTML = html;
- return children(Element$$1.fromDom(div));
+ return children(Element.fromDom(div));
};
var TagBoundaries = [
@@ -1779,8 +1824,11 @@
];
function DomUniverse () {
- var clone$$1 = function (element) {
- return Element$$1.fromDom(element.dom().cloneNode(false));
+ var clone$1 = function (element) {
+ return Element.fromDom(element.dom().cloneNode(false));
+ };
+ var document = function (element) {
+ return element.dom().ownerDocument;
};
var isBoundary = function (element) {
if (!isElement(element))
@@ -1818,13 +1866,13 @@
predicate: descendants
}),
styles: constant({
- get: get$2,
+ get: get$1,
getRaw: getRaw,
set: set$1,
remove: remove$1
}),
attrs: constant({
- get: get$1,
+ get: get,
set: set,
remove: remove,
copyTo: copyAttributesTo
@@ -1843,9 +1891,9 @@
remove: remove$2
}),
create: constant({
- nu: Element$$1.fromTag,
- clone: clone$$1,
- text: Element$$1.fromText
+ nu: Element.fromTag,
+ clone: clone$1,
+ text: Element.fromText
}),
query: constant({
comparePosition: comparePosition,
@@ -1856,10 +1904,11 @@
children: children,
name: name,
parent: parent,
+ document: document,
isText: isText,
isComment: isComment,
isElement: isElement,
- getText: get$3,
+ getText: get$2,
setText: set$2,
isBoundary: isBoundary,
isEmptyTag: isEmptyTag
@@ -1924,16 +1973,16 @@
breakPath: breakPath
};
- var all$3 = function (universe, look, elements, f) {
- var head$$1 = elements[0];
+ var all$1 = function (universe, look, elements, f) {
+ var head = elements[0];
var tail = elements.slice(1);
- return f(universe, look, head$$1, tail);
+ return f(universe, look, head, tail);
};
var oneAll = function (universe, look, elements) {
- return elements.length > 0 ? all$3(universe, look, elements, unsafeOne) : Option.none();
+ return elements.length > 0 ? all$1(universe, look, elements, unsafeOne) : Option.none();
};
- var unsafeOne = function (universe, look, head$$1, tail) {
- var start = look(universe, head$$1);
+ var unsafeOne = function (universe, look, head, tail) {
+ var start = look(universe, head);
return foldr(tail, function (b, a) {
var current = look(universe, a);
return commonElement(universe, b, current);
@@ -1966,8 +2015,8 @@
return startIndex.bind(function (sIndex) {
return endIndex.map(function (eIndex) {
var first = Math.min(sIndex, eIndex);
- var last$$1 = Math.max(sIndex, eIndex);
- return children.slice(first, last$$1 + 1);
+ var last = Math.max(sIndex, eIndex);
+ return children.slice(first, last + 1);
});
});
};
@@ -2250,14 +2299,14 @@
};
var getEdges = function (container, firstSelectedSelector, lastSelectedSelector) {
return descendant$1(container, firstSelectedSelector).bind(function (first) {
- return descendant$1(container, lastSelectedSelector).bind(function (last$$1) {
+ return descendant$1(container, lastSelectedSelector).bind(function (last) {
return DomParent.sharedOne(lookupTable, [
first,
- last$$1
+ last
]).map(function (tbl) {
return {
first: constant(first),
- last: constant(last$$1),
+ last: constant(last),
table: constant(tbl)
};
});
@@ -2280,8 +2329,8 @@
});
};
var shiftSelection = function (boxes, deltaRow, deltaColumn, firstSelectedSelector, lastSelectedSelector) {
- return getLast(boxes, lastSelectedSelector).bind(function (last$$1) {
- return TablePositions.moveBy(last$$1, deltaRow, deltaColumn).bind(function (finish) {
+ return getLast(boxes, lastSelectedSelector).bind(function (last) {
+ return TablePositions.moveBy(last, deltaRow, deltaColumn).bind(function (finish) {
return expandTo(finish, firstSelectedSelector);
});
});
@@ -2342,11 +2391,11 @@
var constructors = [];
var adt = {};
each(cases, function (acase, count) {
- var keys$$1 = keys(acase);
- if (keys$$1.length !== 1) {
+ var keys$1 = keys(acase);
+ if (keys$1.length !== 1) {
throw new Error('one and only one name per case');
}
- var key = keys$$1[0];
+ var key = keys$1[0];
var value = acase[key];
if (adt[key] !== undefined) {
throw new Error('duplicate key detected:' + key);
@@ -2386,7 +2435,7 @@
},
match: match,
log: function (label) {
- console.log(label, {
+ domGlobals.console.log(label, {
constructors: constructors,
constructor: key,
params: args
@@ -2419,7 +2468,7 @@
};
var unmergable = function (cell, selections) {
var hasSpan = function (elem) {
- return has$1(elem, 'rowspan') && parseInt(get$1(elem, 'rowspan'), 10) > 1 || has$1(elem, 'colspan') && parseInt(get$1(elem, 'colspan'), 10) > 1;
+ return has(elem, 'rowspan') && parseInt(get(elem, 'rowspan'), 10) > 1 || has(elem, 'colspan') && parseInt(get(elem, 'colspan'), 10) > 1;
};
var candidates = selection(cell, selections);
return candidates.length > 0 && forall(candidates, hasSpan) ? Option.some(candidates) : Option.none();
@@ -2486,17 +2535,22 @@
return [CopySelected.extract(replica, Ephemera.attributeSelector())];
});
};
- var serializeElement = function (editor, elm) {
+ var serializeElements = function (editor, elements) {
+ return map(elements, function (elm) {
return editor.selection.serializer.serialize(elm.dom(), {});
+ }).join('');
+ };
+ var getTextContent = function (elements) {
+ return map(elements, function (element) {
+ return element.dom().innerText;
+ }).join('');
};
var registerEvents = function (editor, selections, actions, cellSelection) {
editor.on('BeforeGetContent', function (e) {
var multiCellContext = function (cells) {
e.preventDefault();
extractSelected(cells).each(function (elements) {
- e.content = map(elements, function (elm) {
- return serializeElement(editor, elm);
- }).join('');
+ e.content = e.format === 'text' ? getTextContent(elements) : serializeElements(editor, elements);
});
};
if (e.selection === true) {
@@ -2507,15 +2561,14 @@
if (e.selection === true && e.paste === true) {
var cellOpt = Option.from(editor.dom.getParent(editor.selection.getStart(), 'th,td'));
cellOpt.each(function (domCell) {
- var cell = Element$$1.fromDom(domCell);
- var table = TableLookup.table(cell);
- table.bind(function (table) {
+ var cell = Element.fromDom(domCell);
+ TableLookup.table(cell).each(function (table) {
var elements = filter(fromHtml$1(e.content), function (content) {
return name(content) !== 'meta';
});
if (elements.length === 1 && name(elements[0]) === 'table') {
e.preventDefault();
- var doc = Element$$1.fromDom(editor.getDoc());
+ var doc = Element.fromDom(editor.getDoc());
var generators = TableFill.paste(doc);
var targets = TableTargets.paste(cell, elements[0], generators);
actions.pasteCells(table, targets).each(function (rng) {
@@ -2533,16 +2586,18 @@
function Dimension (name, getOffset) {
var set = function (element, h) {
- if (!isNumber(h) && !h.match(/^[0-9]+$/))
- throw name + '.set accepts only positive integer values. Value was ' + h;
+ if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
+ throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
+ }
var dom = element.dom();
- if (isSupported(dom))
+ if (isSupported(dom)) {
dom.style[name] = h + 'px';
+ }
};
var get = function (element) {
var r = getOffset(element);
if (r <= 0 || r === null) {
- var css = get$2(element, name);
+ var css = get$1(element, name);
return parseFloat(css) || 0;
}
return r;
@@ -2550,7 +2605,7 @@
var getOuter = get;
var aggregate = function (element, properties) {
return foldl(properties, function (acc, property) {
- var val = get$2(element, property);
+ var val = get$1(element, property);
var value = val === undefined ? 0 : parseInt(val, 10);
return isNaN(value) ? acc : acc + value;
}, 0);
@@ -2573,7 +2628,7 @@
var dom = element.dom();
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
});
- var get$4 = function (element) {
+ var get$3 = function (element) {
return api$1.get(element);
};
var getOuter = function (element) {
@@ -2583,7 +2638,7 @@
var api$2 = Dimension('width', function (element) {
return element.dom().offsetWidth;
});
- var get$5 = function (element) {
+ var get$4 = function (element) {
return api$2.get(element);
};
var getOuter$1 = function (element) {
@@ -2599,7 +2654,7 @@
return isNaN(num) ? fallback : num;
};
var getProp = function (elm, name, fallback) {
- return toNumber(get$2(elm, name), fallback);
+ return toNumber(get$1(elm, name), fallback);
};
var getCalculatedHeight = function (cell) {
var paddingTop = getProp(cell, 'padding-top', 0);
@@ -2607,15 +2662,15 @@
var borderTop = getProp(cell, 'border-top-width', 0);
var borderBottom = getProp(cell, 'border-bottom-width', 0);
var height = cell.dom().getBoundingClientRect().height;
- var boxSizing = get$2(cell, 'box-sizing');
+ var boxSizing = get$1(cell, 'box-sizing');
var borders = borderTop + borderBottom;
return boxSizing === 'border-box' ? height : height - paddingTop - paddingBottom - borders;
};
var getWidth = function (cell) {
- return getProp(cell, 'width', get$5(cell));
+ return getProp(cell, 'width', get$4(cell));
};
var getHeight = function (cell) {
- return needManualCalc() ? getCalculatedHeight(cell) : getProp(cell, 'height', get$4(cell));
+ return needManualCalc() ? getCalculatedHeight(cell) : getProp(cell, 'height', get$3(cell));
};
var RuntimeSize = {
getWidth: getWidth,
@@ -2647,28 +2702,29 @@
setter(cell, newSize);
return newSize;
};
- var normalizePixelSize = function (value$$1, cell, getter, setter) {
- var number = parseInt(value$$1, 10);
- return endsWith(value$$1, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number;
+ var normalizePixelSize = function (value, cell, getter, setter) {
+ var number = parseInt(value, 10);
+ return endsWith(value, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number;
};
var getTotalHeight = function (cell) {
- var value$$1 = getHeightValue(cell);
- if (!value$$1)
- return get$4(cell);
- return normalizePixelSize(value$$1, cell, get$4, setHeight);
+ var value = getHeightValue(cell);
+ if (!value) {
+ return get$3(cell);
+ }
+ return normalizePixelSize(value, cell, get$3, setHeight);
};
- var get$6 = function (cell, type$$1, f) {
+ var get$5 = function (cell, type, f) {
var v = f(cell);
- var span = getSpan(cell, type$$1);
+ var span = getSpan(cell, type);
return v / span;
};
- var getSpan = function (cell, type$$1) {
- return has$1(cell, type$$1) ? parseInt(get$1(cell, type$$1), 10) : 1;
+ var getSpan = function (cell, type) {
+ return has(cell, type) ? parseInt(get(cell, type), 10) : 1;
};
var getRawWidth = function (element) {
var cssWidth = getRaw(element, 'width');
return cssWidth.fold(function () {
- return Option.from(get$1(element, 'width'));
+ return Option.from(get(element, 'width'));
}, function (width) {
return Option.some(width);
});
@@ -2681,17 +2737,17 @@
var percentMatch = percentageBasedSizeRegex.exec(width);
return parseFloat(percentMatch[1]);
} else {
- var intWidth = get$5(element);
+ var intWidth = get$4(element);
return normalizePercentageWidth(intWidth, tableSize);
}
};
var getPercentageWidth = function (cell, tableSize) {
var width = getRawWidth(cell);
return width.fold(function () {
- var intWidth = get$5(cell);
+ var intWidth = get$4(cell);
return normalizePercentageWidth(intWidth, tableSize);
- }, function (width) {
- return choosePercentageSize(cell, width, tableSize);
+ }, function (w) {
+ return choosePercentageSize(cell, w, tableSize);
});
};
var normalizePixelWidth = function (cellWidth, tableSize) {
@@ -2706,25 +2762,25 @@
var floatWidth = parseFloat(percentMatch[1]);
return normalizePixelWidth(floatWidth, tableSize);
} else {
- return get$5(element);
+ return get$4(element);
}
};
var getPixelWidth = function (cell, tableSize) {
var width = getRawWidth(cell);
return width.fold(function () {
- return get$5(cell);
- }, function (width) {
- return choosePixelSize(cell, width, tableSize);
+ return get$4(cell);
+ }, function (w) {
+ return choosePixelSize(cell, w, tableSize);
});
};
var getHeight$1 = function (cell) {
- return get$6(cell, 'rowspan', getTotalHeight);
+ return get$5(cell, 'rowspan', getTotalHeight);
};
var getGenericWidth = function (cell) {
var width = getRawWidth(cell);
- return width.bind(function (width) {
- if (genericSizeRegex.test(width)) {
- var match = genericSizeRegex.exec(width);
+ return width.bind(function (w) {
+ if (genericSizeRegex.test(w)) {
+ var match = genericSizeRegex.exec(w);
return Option.some({
width: constant(match[1]),
unit: constant(match[3])
@@ -2753,22 +2809,23 @@
var halve = function (main, other) {
var width = Sizes.getGenericWidth(main);
- width.each(function (width) {
- var newWidth = width.width() / 2;
- Sizes.setGenericWidth(main, newWidth, width.unit());
- Sizes.setGenericWidth(other, newWidth, width.unit());
+ width.each(function (w) {
+ var newWidth = w.width() / 2;
+ Sizes.setGenericWidth(main, newWidth, w.unit());
+ Sizes.setGenericWidth(other, newWidth, w.unit());
});
};
var CellMutations = { halve: halve };
var attached = function (element, scope) {
- var doc = scope || Element$$1.fromDom(document.documentElement);
+ var doc = scope || Element.fromDom(domGlobals.document.documentElement);
return ancestor(element, curry(eq, doc)).isSome();
};
var windowOf = function (element) {
var dom = element.dom();
- if (dom === dom.window && element instanceof Window)
+ if (dom === dom.window && element instanceof domGlobals.Window) {
return element;
+ }
return isDocument(element) ? dom.defaultView || dom.parentWindow : null;
};
@@ -2794,7 +2851,7 @@
var absolute = function (element) {
var doc = element.dom().ownerDocument;
var body = doc.body;
- var win = windowOf(Element$$1.fromDom(doc));
+ var win = windowOf(Element.fromDom(doc));
var html = doc.documentElement;
var scrollTop = firstDefinedOrZero(win.pageYOffset, html.scrollTop);
var scrollLeft = firstDefinedOrZero(win.pageXOffset, html.scrollLeft);
@@ -2806,11 +2863,13 @@
var dom = element.dom();
var doc = dom.ownerDocument;
var body = doc.body;
- var html = Element$$1.fromDom(doc.documentElement);
- if (body === dom)
+ var html = Element.fromDom(doc.documentElement);
+ if (body === dom) {
return Position(body.offsetLeft, body.offsetTop);
- if (!attached(element, html))
+ }
+ if (!attached(element, html)) {
return Position(0, 0);
+ }
return boxPosition(dom);
};
@@ -2839,8 +2898,9 @@
return rowInfo(index, getTop(cell) + getOuter(cell));
};
var findPositions = function (getInnerEdge, getOuterEdge, array) {
- if (array.length === 0)
+ if (array.length === 0) {
return [];
+ }
var lines = map(array.slice(1), function (cellOption, index) {
return cellOption.map(function (cell) {
return getInnerEdge(index, cell);
@@ -2888,7 +2948,7 @@
return auto(table).delta(amount, table);
};
var positions = function (cols, table) {
- return auto(table).positions(cols, table);
+ return auto(table).positions(cols);
};
var edge = function (cell) {
return auto(cell).edge(cell);
@@ -2907,355 +2967,7 @@
};
var TableGridSize = { getGridSize: getGridSize };
- var Cell = function (initial) {
- var value = initial;
- var get = function () {
- return value;
- };
- var set = function (v) {
- value = v;
- };
- var clone = function () {
- return Cell(get());
- };
- return {
- get: get,
- set: set,
- clone: clone
- };
- };
-
- var base = function (handleUnsupported, required) {
- return baseWith(handleUnsupported, required, {
- validate: isFunction,
- label: 'function'
- });
- };
- var baseWith = function (handleUnsupported, required, pred) {
- if (required.length === 0)
- throw new Error('You must specify at least one required field.');
- validateStrArr('required', required);
- checkDupes(required);
- return function (obj) {
- var keys$$1 = keys(obj);
- var allReqd = forall(required, function (req) {
- return contains(keys$$1, req);
- });
- if (!allReqd)
- reqMessage(required, keys$$1);
- handleUnsupported(required, keys$$1);
- var invalidKeys = filter(required, function (key) {
- return !pred.validate(obj[key], key);
- });
- if (invalidKeys.length > 0)
- invalidTypeMessage(invalidKeys, pred.label);
- return obj;
- };
- };
- var handleExact = function (required, keys$$1) {
- var unsupported = filter(keys$$1, function (key) {
- return !contains(required, key);
- });
- if (unsupported.length > 0)
- unsuppMessage(unsupported);
- };
- var exactly = function (required) {
- return base(handleExact, required);
- };
-
- var elementToData = function (element) {
- var colspan = has$1(element, 'colspan') ? parseInt(get$1(element, 'colspan'), 10) : 1;
- var rowspan = has$1(element, 'rowspan') ? parseInt(get$1(element, 'rowspan'), 10) : 1;
- return {
- element: constant(element),
- colspan: constant(colspan),
- rowspan: constant(rowspan)
- };
- };
- var modification = function (generators, _toData) {
- contract(generators);
- var position = Cell(Option.none());
- var toData = _toData !== undefined ? _toData : elementToData;
- var nu = function (data) {
- return generators.cell(data);
- };
- var nuFrom = function (element) {
- var data = toData(element);
- return nu(data);
- };
- var add = function (element) {
- var replacement = nuFrom(element);
- if (position.get().isNone())
- position.set(Option.some(replacement));
- recent = Option.some({
- item: element,
- replacement: replacement
- });
- return replacement;
- };
- var recent = Option.none();
- var getOrInit = function (element, comparator) {
- return recent.fold(function () {
- return add(element);
- }, function (p) {
- return comparator(element, p.item) ? p.replacement : add(element);
- });
- };
- return {
- getOrInit: getOrInit,
- cursor: position.get
- };
- };
- var transform = function (scope, tag) {
- return function (generators) {
- var position = Cell(Option.none());
- contract(generators);
- var list = [];
- var find$$1 = function (element, comparator) {
- return find(list, function (x) {
- return comparator(x.item, element);
- });
- };
- var makeNew = function (element) {
- var cell = generators.replace(element, tag, { scope: scope });
- list.push({
- item: element,
- sub: cell
- });
- if (position.get().isNone())
- position.set(Option.some(cell));
- return cell;
- };
- var replaceOrInit = function (element, comparator) {
- return find$$1(element, comparator).fold(function () {
- return makeNew(element);
- }, function (p) {
- return comparator(element, p.item) ? p.sub : makeNew(element);
- });
- };
- return {
- replaceOrInit: replaceOrInit,
- cursor: position.get
- };
- };
- };
- var merging = function (generators) {
- contract(generators);
- var position = Cell(Option.none());
- var combine = function (cell) {
- if (position.get().isNone())
- position.set(Option.some(cell));
- return function () {
- var raw = generators.cell({
- element: constant(cell),
- colspan: constant(1),
- rowspan: constant(1)
- });
- remove$1(raw, 'width');
- remove$1(cell, 'width');
- return raw;
- };
- };
- return {
- combine: combine,
- cursor: position.get
- };
- };
- var contract = exactly([
- 'cell',
- 'row',
- 'replace',
- 'gap'
- ]);
- var Generators = {
- modification: modification,
- transform: transform,
- merging: merging
- };
-
- var blockList = [
- 'body',
- 'p',
- 'div',
- 'article',
- 'aside',
- 'figcaption',
- 'figure',
- 'footer',
- 'header',
- 'nav',
- 'section',
- 'ol',
- 'ul',
- 'table',
- 'thead',
- 'tfoot',
- 'tbody',
- 'caption',
- 'tr',
- 'td',
- 'th',
- 'h1',
- 'h2',
- 'h3',
- 'h4',
- 'h5',
- 'h6',
- 'blockquote',
- 'pre',
- 'address'
- ];
- var isList = function (universe, item) {
- var tagName = universe.property().name(item);
- return contains([
- 'ol',
- 'ul'
- ], tagName);
- };
- var isBlock = function (universe, item) {
- var tagName = universe.property().name(item);
- return contains(blockList, tagName);
- };
- var isFormatting = function (universe, item) {
- var tagName = universe.property().name(item);
- return contains([
- 'address',
- 'pre',
- 'p',
- 'h1',
- 'h2',
- 'h3',
- 'h4',
- 'h5',
- 'h6'
- ], tagName);
- };
- var isHeading = function (universe, item) {
- var tagName = universe.property().name(item);
- return contains([
- 'h1',
- 'h2',
- 'h3',
- 'h4',
- 'h5',
- 'h6'
- ], tagName);
- };
- var isContainer = function (universe, item) {
- return contains([
- 'div',
- 'li',
- 'td',
- 'th',
- 'blockquote',
- 'body',
- 'caption'
- ], universe.property().name(item));
- };
- var isEmptyTag = function (universe, item) {
- return contains([
- 'br',
- 'img',
- 'hr',
- 'input'
- ], universe.property().name(item));
- };
- var isFrame = function (universe, item) {
- return universe.property().name(item) === 'iframe';
- };
- var isInline = function (universe, item) {
- return !(isBlock(universe, item) || isEmptyTag(universe, item)) && universe.property().name(item) !== 'li';
- };
- var Structure = {
- isBlock: isBlock,
- isList: isList,
- isFormatting: isFormatting,
- isHeading: isHeading,
- isContainer: isContainer,
- isEmptyTag: isEmptyTag,
- isFrame: isFrame,
- isInline: isInline
- };
-
- var universe$1 = DomUniverse();
- var isBlock$1 = function (element) {
- return Structure.isBlock(universe$1, element);
- };
- var isList$1 = function (element) {
- return Structure.isList(universe$1, element);
- };
- var isFormatting$1 = function (element) {
- return Structure.isFormatting(universe$1, element);
- };
- var isHeading$1 = function (element) {
- return Structure.isHeading(universe$1, element);
- };
- var isContainer$1 = function (element) {
- return Structure.isContainer(universe$1, element);
- };
- var isEmptyTag$1 = function (element) {
- return Structure.isEmptyTag(universe$1, element);
- };
- var isFrame$1 = function (element) {
- return Structure.isFrame(universe$1, element);
- };
- var isInline$1 = function (element) {
- return Structure.isInline(universe$1, element);
- };
- var DomStructure = {
- isBlock: isBlock$1,
- isList: isList$1,
- isFormatting: isFormatting$1,
- isHeading: isHeading$1,
- isContainer: isContainer$1,
- isEmptyTag: isEmptyTag$1,
- isFrame: isFrame$1,
- isInline: isInline$1
- };
-
- var merge = function (cells) {
- var isBr = function (el) {
- return name(el) === 'br';
- };
- var advancedBr = function (children$$1) {
- return forall(children$$1, function (c) {
- return isBr(c) || isText(c) && get$3(c).trim().length === 0;
- });
- };
- var isListItem = function (el) {
- return name(el) === 'li' || ancestor(el, DomStructure.isList).isSome();
- };
- var siblingIsBlock = function (el) {
- return nextSibling(el).map(function (rightSibling) {
- if (DomStructure.isBlock(rightSibling))
- return true;
- if (DomStructure.isEmptyTag(rightSibling)) {
- return name(rightSibling) === 'img' ? false : true;
- }
- }).getOr(false);
- };
- var markCell = function (cell) {
- return last$2(cell).bind(function (rightEdge) {
- var rightSiblingIsBlock = siblingIsBlock(rightEdge);
- return parent(rightEdge).map(function (parent$$1) {
- return rightSiblingIsBlock === true || isListItem(parent$$1) || isBr(rightEdge) || DomStructure.isBlock(parent$$1) && !eq(cell, parent$$1) ? [] : [Element$$1.fromTag('br')];
- });
- }).getOr([]);
- };
- var markContent = function () {
- var content = bind(cells, function (cell) {
- var children$$1 = children(cell);
- return advancedBr(children$$1) ? [] : children$$1.concat(markCell(cell));
- });
- return content.length === 0 ? [Element$$1.fromTag('br')] : content;
- };
- var contents = markContent();
- empty(cells[0]);
- append$1(cells[0], contents);
- };
- var TableContent = { merge: merge };
-
- var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
var shallow$1 = function (old, nu) {
return nu;
};
@@ -3270,14 +2982,14 @@
for (var j = 0; j < objects.length; j++) {
var curObject = objects[j];
for (var key in curObject)
- if (hasOwnProperty$1.call(curObject, key)) {
+ if (hasOwnProperty.call(curObject, key)) {
ret[key] = merger(ret[key], curObject[key]);
}
}
return ret;
};
};
- var merge$1 = baseMerge(shallow$1);
+ var merge = baseMerge(shallow$1);
var cat = function (arr) {
var r = [];
@@ -3299,137 +3011,19 @@
return Option.none();
};
- var addCell = function (gridRow, index, cell) {
- var cells = gridRow.cells();
- var before = cells.slice(0, index);
- var after = cells.slice(index);
- var newCells = before.concat([cell]).concat(after);
- return setCells(gridRow, newCells);
- };
- var mutateCell = function (gridRow, index, cell) {
- var cells = gridRow.cells();
- cells[index] = cell;
- };
- var setCells = function (gridRow, cells) {
- return Structs.rowcells(cells, gridRow.section());
- };
- var mapCells = function (gridRow, f) {
- var cells = gridRow.cells();
- var r = map(cells, f);
- return Structs.rowcells(r, gridRow.section());
- };
- var getCell = function (gridRow, index) {
- return gridRow.cells()[index];
- };
- var getCellElement = function (gridRow, index) {
- return getCell(gridRow, index).element();
- };
- var cellLength = function (gridRow) {
- return gridRow.cells().length;
- };
- var GridRow = {
- addCell: addCell,
- setCells: setCells,
- mutateCell: mutateCell,
- getCell: getCell,
- getCellElement: getCellElement,
- mapCells: mapCells,
- cellLength: cellLength
- };
-
- var getColumn = function (grid, index) {
- return map(grid, function (row) {
- return GridRow.getCell(row, index);
- });
- };
- var getRow = function (grid, index) {
- return grid[index];
- };
- var findDiff = function (xs, comp) {
- if (xs.length === 0)
- return 0;
- var first = xs[0];
- var index = findIndex(xs, function (x) {
- return !comp(first.element(), x.element());
- });
- return index.fold(function () {
- return xs.length;
- }, function (ind) {
- return ind;
- });
- };
- var subgrid = function (grid, row, column, comparator) {
- var restOfRow = getRow(grid, row).cells().slice(column);
- var endColIndex = findDiff(restOfRow, comparator);
- var restOfColumn = getColumn(grid, column).slice(row);
- var endRowIndex = findDiff(restOfColumn, comparator);
- return {
- colspan: constant(endColIndex),
- rowspan: constant(endRowIndex)
- };
- };
- var TableGrid = { subgrid: subgrid };
-
- var toDetails = function (grid, comparator) {
- var seen = map(grid, function (row, ri) {
- return map(row.cells(), function (col, ci) {
- return false;
- });
- });
- var updateSeen = function (ri, ci, rowspan, colspan) {
- for (var r = ri; r < ri + rowspan; r++) {
- for (var c = ci; c < ci + colspan; c++) {
- seen[r][c] = true;
- }
- }
- };
- return map(grid, function (row, ri) {
- var details = bind(row.cells(), function (cell, ci) {
- if (seen[ri][ci] === false) {
- var result = TableGrid.subgrid(grid, ri, ci, comparator);
- updateSeen(ri, ci, result.rowspan(), result.colspan());
- return [Structs.detailnew(cell.element(), result.rowspan(), result.colspan(), cell.isNew())];
- } else {
- return [];
- }
- });
- return Structs.rowdetails(details, row.section());
- });
- };
- var toGrid = function (warehouse, generators, isNew) {
- var grid = [];
- for (var i = 0; i < warehouse.grid().rows(); i++) {
- var rowCells = [];
- for (var j = 0; j < warehouse.grid().columns(); j++) {
- var element = Warehouse.getAt(warehouse, i, j).map(function (item) {
- return Structs.elementnew(item.element(), isNew);
- }).getOrThunk(function () {
- return Structs.elementnew(generators.gap(), true);
- });
- rowCells.push(element);
- }
- var row = Structs.rowcells(rowCells, warehouse.all()[i].section());
- grid.push(row);
- }
- return grid;
- };
- var Transitions = {
- toDetails: toDetails,
- toGrid: toGrid
- };
-
var setIfNot = function (element, property, value, ignore) {
- if (value === ignore)
+ if (value === ignore) {
remove(element, property);
- else
+ } else {
set(element, property, value);
+ }
};
var render = function (table, grid) {
var newRows = [];
var newCells = [];
var renderSection = function (gridSection, sectionName) {
var section = child$2(table, sectionName).getOrThunk(function () {
- var tb = Element$$1.fromTag(sectionName, owner(table).dom());
+ var tb = Element.fromTag(sectionName, owner(table).dom());
append(table, tb);
return tb;
});
@@ -3504,6 +3098,67 @@
copy: copy$2
};
+ var read = function (element, attr) {
+ var value = get(element, attr);
+ return value === undefined || value === '' ? [] : value.split(' ');
+ };
+ var add = function (element, attr, id) {
+ var old = read(element, attr);
+ var nu = old.concat([id]);
+ set(element, attr, nu.join(' '));
+ return true;
+ };
+ var remove$3 = function (element, attr, id) {
+ var nu = filter(read(element, attr), function (v) {
+ return v !== id;
+ });
+ if (nu.length > 0) {
+ set(element, attr, nu.join(' '));
+ } else {
+ remove(element, attr);
+ }
+ return false;
+ };
+
+ var supports = function (element) {
+ return element.dom().classList !== undefined;
+ };
+ var get$6 = function (element) {
+ return read(element, 'class');
+ };
+ var add$1 = function (element, clazz) {
+ return add(element, 'class', clazz);
+ };
+ var remove$4 = function (element, clazz) {
+ return remove$3(element, 'class', clazz);
+ };
+
+ var add$2 = function (element, clazz) {
+ if (supports(element)) {
+ element.dom().classList.add(clazz);
+ } else {
+ add$1(element, clazz);
+ }
+ };
+ var cleanClass = function (element) {
+ var classList = supports(element) ? element.dom().classList : get$6(element);
+ if (classList.length === 0) {
+ remove(element, 'class');
+ }
+ };
+ var remove$5 = function (element, clazz) {
+ if (supports(element)) {
+ var classList = element.dom().classList;
+ classList.remove(clazz);
+ } else {
+ remove$4(element, clazz);
+ }
+ cleanClass(element);
+ };
+ var has$1 = function (element, clazz) {
+ return supports(element) && element.dom().classList.contains(clazz);
+ };
+
var repeat = function (repititions, f) {
var r = [];
for (var i = 0; i < repititions; i++) {
@@ -3511,7 +3166,7 @@
}
return r;
};
- var range$1 = function (start, end) {
+ var range = function (start, end) {
var r = [];
for (var i = start; i < end; i++) {
r.push(i);
@@ -3530,8 +3185,9 @@
return result;
};
var deduce = function (xs, index) {
- if (index < 0 || index >= xs.length - 1)
+ if (index < 0 || index >= xs.length - 1) {
return Option.none();
+ }
var current = xs[index].fold(function () {
var rest = reverse(xs.slice(0, index));
return findMap(rest, function (a, i) {
@@ -3573,7 +3229,7 @@
};
var Util = {
repeat: repeat,
- range: range$1,
+ range: range,
unique: unique,
deduce: deduce
};
@@ -3581,10 +3237,10 @@
var columns = function (warehouse) {
var grid = warehouse.grid();
var cols = Util.range(0, grid.columns());
- var rows = Util.range(0, grid.rows());
+ var rowsArr = Util.range(0, grid.rows());
return map(cols, function (col) {
var getBlock = function () {
- return bind(rows, function (r) {
+ return bind(rowsArr, function (r) {
return Warehouse.getAt(warehouse, r, col).filter(function (detail) {
return detail.column() === col;
}).fold(constant([]), function (detail) {
@@ -3613,9 +3269,9 @@
};
var rows$1 = function (warehouse) {
var grid = warehouse.grid();
- var rows = Util.range(0, grid.rows());
+ var rowsArr = Util.range(0, grid.rows());
var cols = Util.range(0, grid.columns());
- return map(rows, function (row) {
+ return map(rowsArr, function (row) {
var getBlock = function () {
return bind(cols, function (c) {
return Warehouse.getAt(warehouse, row, c).filter(function (detail) {
@@ -3639,8 +3295,19 @@
rows: rows$1
};
+ var css = function (namespace) {
+ var dashNamespace = namespace.replace(/\./g, '-');
+ var resolve = function (str) {
+ return dashNamespace + '-' + str;
+ };
+ return { resolve: resolve };
+ };
+
+ var styles = css('ephox-snooker');
+ var Styles = { resolve: styles.resolve };
+
var col = function (column, x, y, w, h) {
- var blocker = Element$$1.fromTag('div');
+ var blocker = Element.fromTag('div');
setAll$1(blocker, {
position: 'absolute',
left: x - w / 2 + 'px',
@@ -3654,8 +3321,8 @@
});
return blocker;
};
- var row$1 = function (row, x, y, w, h) {
- var blocker = Element$$1.fromTag('div');
+ var row$1 = function (r, x, y, w, h) {
+ var blocker = Element.fromTag('div');
setAll$1(blocker, {
position: 'absolute',
left: x + 'px',
@@ -3664,7 +3331,7 @@
width: w + 'px'
});
setAll(blocker, {
- 'data-row': row,
+ 'data-row': r,
'role': 'presentation'
});
return blocker;
@@ -3674,75 +3341,6 @@
row: row$1
};
- var css = function (namespace) {
- var dashNamespace = namespace.replace(/\./g, '-');
- var resolve = function (str) {
- return dashNamespace + '-' + str;
- };
- return { resolve: resolve };
- };
-
- var styles = css('ephox-snooker');
- var Styles = { resolve: styles.resolve };
-
- var read = function (element, attr) {
- var value = get$1(element, attr);
- return value === undefined || value === '' ? [] : value.split(' ');
- };
- var add = function (element, attr, id) {
- var old = read(element, attr);
- var nu = old.concat([id]);
- set(element, attr, nu.join(' '));
- return true;
- };
- var remove$3 = function (element, attr, id) {
- var nu = filter(read(element, attr), function (v) {
- return v !== id;
- });
- if (nu.length > 0)
- set(element, attr, nu.join(' '));
- else
- remove(element, attr);
- return false;
- };
-
- var supports = function (element) {
- return element.dom().classList !== undefined;
- };
- var get$7 = function (element) {
- return read(element, 'class');
- };
- var add$1 = function (element, clazz) {
- return add(element, 'class', clazz);
- };
- var remove$4 = function (element, clazz) {
- return remove$3(element, 'class', clazz);
- };
-
- var add$2 = function (element, clazz) {
- if (supports(element))
- element.dom().classList.add(clazz);
- else
- add$1(element, clazz);
- };
- var cleanClass = function (element) {
- var classList = supports(element) ? element.dom().classList : get$7(element);
- if (classList.length === 0) {
- remove(element, 'class');
- }
- };
- var remove$5 = function (element, clazz) {
- if (supports(element)) {
- var classList = element.dom().classList;
- classList.remove(clazz);
- } else
- remove$4(element, clazz);
- cleanClass(element);
- };
- var has$2 = function (element, clazz) {
- return supports(element) && element.dom().classList.contains(clazz);
- };
-
var resizeBar = Styles.resolve('resizer-bar');
var resizeRowBar = Styles.resolve('resizer-rows');
var resizeColBar = Styles.resolve('resizer-cols');
@@ -3805,10 +3403,10 @@
});
};
var isRowBar = function (element) {
- return has$2(element, resizeRowBar);
+ return has$1(element, resizeRowBar);
};
var isColBar = function (element) {
- return has$2(element, resizeColBar);
+ return has$1(element, resizeColBar);
};
var Bars = {
refresh: refresh,
@@ -3819,6 +3417,126 @@
isColBar: isColBar
};
+ var addCell = function (gridRow, index, cell) {
+ var cells = gridRow.cells();
+ var before = cells.slice(0, index);
+ var after = cells.slice(index);
+ var newCells = before.concat([cell]).concat(after);
+ return setCells(gridRow, newCells);
+ };
+ var mutateCell = function (gridRow, index, cell) {
+ var cells = gridRow.cells();
+ cells[index] = cell;
+ };
+ var setCells = function (gridRow, cells) {
+ return Structs.rowcells(cells, gridRow.section());
+ };
+ var mapCells = function (gridRow, f) {
+ var cells = gridRow.cells();
+ var r = map(cells, f);
+ return Structs.rowcells(r, gridRow.section());
+ };
+ var getCell = function (gridRow, index) {
+ return gridRow.cells()[index];
+ };
+ var getCellElement = function (gridRow, index) {
+ return getCell(gridRow, index).element();
+ };
+ var cellLength = function (gridRow) {
+ return gridRow.cells().length;
+ };
+ var GridRow = {
+ addCell: addCell,
+ setCells: setCells,
+ mutateCell: mutateCell,
+ getCell: getCell,
+ getCellElement: getCellElement,
+ mapCells: mapCells,
+ cellLength: cellLength
+ };
+
+ var getColumn = function (grid, index) {
+ return map(grid, function (row) {
+ return GridRow.getCell(row, index);
+ });
+ };
+ var getRow = function (grid, index) {
+ return grid[index];
+ };
+ var findDiff = function (xs, comp) {
+ if (xs.length === 0) {
+ return 0;
+ }
+ var first = xs[0];
+ var index = findIndex(xs, function (x) {
+ return !comp(first.element(), x.element());
+ });
+ return index.fold(function () {
+ return xs.length;
+ }, function (ind) {
+ return ind;
+ });
+ };
+ var subgrid = function (grid, row, column, comparator) {
+ var restOfRow = getRow(grid, row).cells().slice(column);
+ var endColIndex = findDiff(restOfRow, comparator);
+ var restOfColumn = getColumn(grid, column).slice(row);
+ var endRowIndex = findDiff(restOfColumn, comparator);
+ return {
+ colspan: constant(endColIndex),
+ rowspan: constant(endRowIndex)
+ };
+ };
+ var TableGrid = { subgrid: subgrid };
+
+ var toDetails = function (grid, comparator) {
+ var seen = map(grid, function (row, ri) {
+ return map(row.cells(), function (col, ci) {
+ return false;
+ });
+ });
+ var updateSeen = function (ri, ci, rowspan, colspan) {
+ for (var r = ri; r < ri + rowspan; r++) {
+ for (var c = ci; c < ci + colspan; c++) {
+ seen[r][c] = true;
+ }
+ }
+ };
+ return map(grid, function (row, ri) {
+ var details = bind(row.cells(), function (cell, ci) {
+ if (seen[ri][ci] === false) {
+ var result = TableGrid.subgrid(grid, ri, ci, comparator);
+ updateSeen(ri, ci, result.rowspan(), result.colspan());
+ return [Structs.detailnew(cell.element(), result.rowspan(), result.colspan(), cell.isNew())];
+ } else {
+ return [];
+ }
+ });
+ return Structs.rowdetails(details, row.section());
+ });
+ };
+ var toGrid = function (warehouse, generators, isNew) {
+ var grid = [];
+ for (var i = 0; i < warehouse.grid().rows(); i++) {
+ var rowCells = [];
+ for (var j = 0; j < warehouse.grid().columns(); j++) {
+ var element = Warehouse.getAt(warehouse, i, j).map(function (item) {
+ return Structs.elementnew(item.element(), isNew);
+ }).getOrThunk(function () {
+ return Structs.elementnew(generators.gap(), true);
+ });
+ rowCells.push(element);
+ }
+ var row = Structs.rowcells(rowCells, warehouse.all()[i].section());
+ grid.push(row);
+ }
+ return grid;
+ };
+ var Transitions = {
+ toDetails: toDetails,
+ toGrid: toGrid
+ };
+
var fromWarehouse = function (warehouse, generators) {
return Transitions.toGrid(warehouse, generators, false);
};
@@ -3887,7 +3605,7 @@
var onPaste = function (warehouse, target) {
return TableLookup.cell(target.element()).bind(function (cell) {
return findInWarehouse(warehouse, cell).map(function (details) {
- return merge$1(details, {
+ return merge(details, {
generators: target.generators,
clipboard: target.clipboard
});
@@ -3901,7 +3619,7 @@
});
});
var cells = cat(details);
- return cells.length > 0 ? Option.some(merge$1({ cells: cells }, {
+ return cells.length > 0 ? Option.some(merge({ cells: cells }, {
generators: target.generators,
clipboard: target.clipboard
})) : Option.none();
@@ -3932,18 +3650,21 @@
onUnmergable: onUnmergable
};
- var value$1 = function (o) {
+ var value = function (o) {
var is = function (v) {
return o === v;
};
var or = function (opt) {
- return value$1(o);
+ return value(o);
};
var orThunk = function (f) {
- return value$1(o);
+ return value(o);
};
var map = function (f) {
- return value$1(f(o));
+ return value(f(o));
+ };
+ var mapError = function (f) {
+ return value(o);
};
var each = function (f) {
f(o);
@@ -3974,6 +3695,7 @@
orThunk: orThunk,
fold: fold,
map: map,
+ mapError: mapError,
each: each,
bind: bind,
exists: exists,
@@ -3997,6 +3719,9 @@
var map = function (f) {
return error(message);
};
+ var mapError = function (f) {
+ return error(f(message));
+ };
var bind = function (f) {
return error(message);
};
@@ -4014,6 +3739,7 @@
orThunk: orThunk,
fold: fold,
map: map,
+ mapError: mapError,
each: noop,
bind: bind,
exists: never,
@@ -4022,13 +3748,14 @@
};
};
var Result = {
- value: value$1,
+ value: value,
error: error
};
var measure = function (startAddress, gridA, gridB) {
- if (startAddress.row() >= gridA.length || startAddress.column() > GridRow.cellLength(gridA[0]))
+ if (startAddress.row() >= gridA.length || startAddress.column() > GridRow.cellLength(gridA[0])) {
return Result.error('invalid start address out of table bounds, row: ' + startAddress.row() + ', column: ' + startAddress.column());
+ }
var rowRemainder = gridA.slice(startAddress.row());
var colRemainder = rowRemainder[0].cells().slice(startAddress.column());
var colRequired = GridRow.cellLength(gridB[0]);
@@ -4074,9 +3801,10 @@
tailor: tailor
};
- var merge$2 = function (grid, bounds, comparator, substitution) {
- if (grid.length === 0)
+ var merge$1 = function (grid, bounds, comparator, substitution) {
+ if (grid.length === 0) {
return grid;
+ }
for (var i = bounds.startRow(); i <= bounds.finishRow(); i++) {
for (var j = bounds.startCol(); j <= bounds.finishCol(); j++) {
GridRow.mutateCell(grid[i], j, Structs.elementnew(substitution(), false));
@@ -4112,8 +3840,8 @@
var cells = uniqueCells(rowPrevCells, comparator);
each(cells, function (cell) {
var replacement = Option.none();
- for (var i = index; i < grid.length; i++) {
- for (var j = 0; j < GridRow.cellLength(grid[0]); j++) {
+ var _loop_1 = function (i) {
+ var _loop_2 = function (j) {
var current = grid[i].cells()[j];
var isToReplace = comparator(current.element(), cell.element());
if (isToReplace) {
@@ -4124,14 +3852,20 @@
GridRow.mutateCell(grid[i], j, Structs.elementnew(sub, true));
});
}
+ };
+ for (var j = 0; j < GridRow.cellLength(grid[0]); j++) {
+ _loop_2(j);
}
+ };
+ for (var i = index; i < grid.length; i++) {
+ _loop_1(i);
}
});
}
return grid;
};
var MergingOperations = {
- merge: merge$2,
+ merge: merge$1,
unmerge: unmerge,
splitRows: splitRows
};
@@ -4161,7 +3895,7 @@
}
return gridA;
};
- var merge$3 = function (startAddress, gridA, gridB, generator, comparator) {
+ var merge$2 = function (startAddress, gridA, gridB, generator, comparator) {
var result = Fitment.measure(startAddress, gridA, gridB);
return result.map(function (delta) {
var fittedGrid = Fitment.tailor(gridA, delta, generator);
@@ -4177,7 +3911,7 @@
return fittedOldGrid.slice(0, index).concat(fittedNewGrid).concat(fittedOldGrid.slice(index, fittedOldGrid.length));
};
var TableMerge = {
- merge: merge$3,
+ merge: merge$2,
insert: insert
};
@@ -4237,6 +3971,10 @@
deleteColumnsAt: deleteColumnsAt
};
+ var get$7 = function (element) {
+ return element.dom().textContent;
+ };
+
var replaceIn = function (grid, targets, comparator, substitution) {
var isTarget = function (cell) {
return exists(targets, function (target) {
@@ -4270,9 +4008,73 @@
});
return replaceIn(grid, targets, comparator, substitution);
};
+ var sortTableRows = function (grid, index, comparator, ascending) {
+ var grouped = groupBy(grid, function (row) {
+ return name(GridRow.getCell(row, index).element());
+ });
+ var sortGroup = function (group) {
+ var texted = map(group, function (row) {
+ var cell = GridRow.getCell(row, index);
+ var text = get$7(cell.element());
+ return {
+ row: row,
+ text: text
+ };
+ });
+ var sorted = sort(texted, function (rowA, rowB) {
+ var compared = comparator(rowA.text, rowB.text);
+ return ascending ? compared : compared * -1;
+ });
+ return map(sorted, function (sortedRow) {
+ return sortedRow.row;
+ });
+ };
+ return bind(grouped, function (group) {
+ return name(GridRow.getCell(group[0], index).element()) === 'th' ? group : sortGroup(group);
+ });
+ };
+ var sortTableColumns = function (grid, index, comparator, ascending) {
+ var targetRow = grid[index].cells();
+ var targetReferences = map(targetRow, function (cell) {
+ return get$7(cell.element());
+ });
+ var zip = function (row) {
+ var zippedCells = map(row.cells(), function (cell, i) {
+ return {
+ cell: cell,
+ reference: targetRow[i],
+ referenceText: targetReferences[i]
+ };
+ });
+ return {
+ zippedCells: zippedCells,
+ section: row.section()
+ };
+ };
+ var unzip = function (row) {
+ var grouped = groupBy(row.zippedCells, function (zippedCell) {
+ return name(zippedCell.reference.element());
+ });
+ var sorted = bind(grouped, function (group) {
+ return name(group[0].reference.element()) === 'th' ? group : sort(group, function (cellA, cellB) {
+ var compared = comparator(cellA.referenceText, cellB.referenceText);
+ return ascending ? compared : compared * -1;
+ });
+ });
+ var unzippedCells = map(sorted, function (sortedCell) {
+ return sortedCell.cell;
+ });
+ return Structs.rowcells(unzippedCells, row.section);
+ };
+ var zippedGrid = map(grid, zip);
+ var unzipped = map(zippedGrid, unzip);
+ return unzipped;
+ };
var TransformOperations = {
replaceColumn: replaceColumn,
- replaceRow: replaceRow
+ replaceRow: replaceRow,
+ sortTableRows: sortTableRows,
+ sortTableColumns: sortTableColumns
};
var none$1 = function () {
@@ -4312,16 +4114,21 @@
};
var neighbours$1 = function (input, index) {
- if (input.length === 0)
+ if (input.length === 0) {
return ColumnContext.none();
- if (input.length === 1)
+ }
+ if (input.length === 1) {
return ColumnContext.only(0);
- if (index === 0)
+ }
+ if (index === 0) {
return ColumnContext.left(0, 1);
- if (index === input.length - 1)
+ }
+ if (index === input.length - 1) {
return ColumnContext.right(index - 1, index);
- if (index > 0 && index < input.length - 1)
+ }
+ if (index > 0 && index < input.length - 1) {
return ColumnContext.middle(index - 1, index, index + 1);
+ }
return ColumnContext.none();
};
var determine = function (input, column, step, tableSize) {
@@ -4367,7 +4174,7 @@
var Deltas = { determine: determine };
var getSpan$1 = function (cell, type) {
- return has$1(cell, type) && parseInt(get$1(cell, type), 10) > 1;
+ return has(cell, type) && parseInt(get(cell, type), 10) > 1;
};
var hasColspan = function (cell) {
return getSpan$1(cell, 'colspan');
@@ -4376,7 +4183,7 @@
return getSpan$1(cell, 'rowspan');
};
var getInt = function (element, property) {
- return parseInt(get$2(element, property), 10);
+ return parseInt(get$1(element, property), 10);
};
var CellUtils = {
hasColspan: hasColspan,
@@ -4512,12 +4319,12 @@
var percentageSize = function (width, element) {
var floatWidth = parseFloat(width);
- var pixelWidth = get$5(element);
+ var pixelWidth = get$4(element);
var getCellDelta = function (delta) {
return delta / pixelWidth * 100;
};
- var singleColumnWidth = function (width, _delta) {
- return [100 - width];
+ var singleColumnWidth = function (w, _delta) {
+ return [100 - w];
};
var minCellWidth = function () {
return CellUtils.minWidth() / pixelWidth * 100;
@@ -4540,9 +4347,9 @@
var pixelSize = function (width) {
var intWidth = parseInt(width, 10);
var getCellDelta = identity;
- var singleColumnWidth = function (width, delta) {
- var newNext = Math.max(CellUtils.minWidth(), width + delta);
- return [newNext - width];
+ var singleColumnWidth = function (w, delta) {
+ var newNext = Math.max(CellUtils.minWidth(), w + delta);
+ return [newNext - w];
};
var setTableWidth = function (table, newWidths, _delta) {
var total = foldr(newWidths, function (b, a) {
@@ -4569,17 +4376,17 @@
var pixelMatch = Sizes.pixelBasedSizeRegex().exec(width);
return pixelSize(pixelMatch[1]);
} else {
- var fallbackWidth = get$5(element);
+ var fallbackWidth = get$4(element);
return pixelSize(fallbackWidth);
}
};
var getTableSize = function (element) {
var width = Sizes.getRawWidth(element);
return width.fold(function () {
- var fallbackWidth = get$5(element);
+ var fallbackWidth = get$4(element);
return pixelSize(fallbackWidth);
- }, function (width) {
- return chooseSize(element, width);
+ }, function (w) {
+ return chooseSize(element, w);
});
};
var TableSize = { getTableSize: getTableSize };
@@ -4642,7 +4449,7 @@
return a + b;
}, 0);
if (newSizes.length > 0) {
- tableSize.setElementWidth(table, total);
+ tableSize.setTableWidth(table, total);
}
};
var Adjustments = {
@@ -4651,10 +4458,363 @@
adjustWidthTo: adjustWidthTo
};
+ var Cell = function (initial) {
+ var value = initial;
+ var get = function () {
+ return value;
+ };
+ var set = function (v) {
+ value = v;
+ };
+ var clone = function () {
+ return Cell(get());
+ };
+ return {
+ get: get,
+ set: set,
+ clone: clone
+ };
+ };
+
+ var base = function (handleUnsupported, required) {
+ return baseWith(handleUnsupported, required, {
+ validate: isFunction,
+ label: 'function'
+ });
+ };
+ var baseWith = function (handleUnsupported, required, pred) {
+ if (required.length === 0)
+ throw new Error('You must specify at least one required field.');
+ validateStrArr('required', required);
+ checkDupes(required);
+ return function (obj) {
+ var keys$1 = keys(obj);
+ var allReqd = forall(required, function (req) {
+ return contains(keys$1, req);
+ });
+ if (!allReqd)
+ reqMessage(required, keys$1);
+ handleUnsupported(required, keys$1);
+ var invalidKeys = filter(required, function (key) {
+ return !pred.validate(obj[key], key);
+ });
+ if (invalidKeys.length > 0)
+ invalidTypeMessage(invalidKeys, pred.label);
+ return obj;
+ };
+ };
+ var handleExact = function (required, keys) {
+ var unsupported = filter(keys, function (key) {
+ return !contains(required, key);
+ });
+ if (unsupported.length > 0)
+ unsuppMessage(unsupported);
+ };
+ var exactly = function (required) {
+ return base(handleExact, required);
+ };
+
+ var elementToData = function (element) {
+ var colspan = has(element, 'colspan') ? parseInt(get(element, 'colspan'), 10) : 1;
+ var rowspan = has(element, 'rowspan') ? parseInt(get(element, 'rowspan'), 10) : 1;
+ return {
+ element: constant(element),
+ colspan: constant(colspan),
+ rowspan: constant(rowspan)
+ };
+ };
+ var modification = function (generators, _toData) {
+ contract(generators);
+ var position = Cell(Option.none());
+ var toData = _toData !== undefined ? _toData : elementToData;
+ var nu = function (data) {
+ return generators.cell(data);
+ };
+ var nuFrom = function (element) {
+ var data = toData(element);
+ return nu(data);
+ };
+ var add = function (element) {
+ var replacement = nuFrom(element);
+ if (position.get().isNone()) {
+ position.set(Option.some(replacement));
+ }
+ recent = Option.some({
+ item: element,
+ replacement: replacement
+ });
+ return replacement;
+ };
+ var recent = Option.none();
+ var getOrInit = function (element, comparator) {
+ return recent.fold(function () {
+ return add(element);
+ }, function (p) {
+ return comparator(element, p.item) ? p.replacement : add(element);
+ });
+ };
+ return {
+ getOrInit: getOrInit,
+ cursor: position.get
+ };
+ };
+ var transform = function (scope, tag) {
+ return function (generators) {
+ var position = Cell(Option.none());
+ contract(generators);
+ var list = [];
+ var find$1 = function (element, comparator) {
+ return find(list, function (x) {
+ return comparator(x.item, element);
+ });
+ };
+ var makeNew = function (element) {
+ var cell = generators.replace(element, tag, { scope: scope });
+ list.push({
+ item: element,
+ sub: cell
+ });
+ if (position.get().isNone()) {
+ position.set(Option.some(cell));
+ }
+ return cell;
+ };
+ var replaceOrInit = function (element, comparator) {
+ return find$1(element, comparator).fold(function () {
+ return makeNew(element);
+ }, function (p) {
+ return comparator(element, p.item) ? p.sub : makeNew(element);
+ });
+ };
+ return {
+ replaceOrInit: replaceOrInit,
+ cursor: position.get
+ };
+ };
+ };
+ var merging = function (generators) {
+ contract(generators);
+ var position = Cell(Option.none());
+ var combine = function (cell) {
+ if (position.get().isNone()) {
+ position.set(Option.some(cell));
+ }
+ return function () {
+ var raw = generators.cell({
+ element: constant(cell),
+ colspan: constant(1),
+ rowspan: constant(1)
+ });
+ remove$1(raw, 'width');
+ remove$1(cell, 'width');
+ return raw;
+ };
+ };
+ return {
+ combine: combine,
+ cursor: position.get
+ };
+ };
+ var contract = exactly([
+ 'cell',
+ 'row',
+ 'replace',
+ 'gap'
+ ]);
+ var Generators = {
+ modification: modification,
+ transform: transform,
+ merging: merging
+ };
+
+ var blockList = [
+ 'body',
+ 'p',
+ 'div',
+ 'article',
+ 'aside',
+ 'figcaption',
+ 'figure',
+ 'footer',
+ 'header',
+ 'nav',
+ 'section',
+ 'ol',
+ 'ul',
+ 'table',
+ 'thead',
+ 'tfoot',
+ 'tbody',
+ 'caption',
+ 'tr',
+ 'td',
+ 'th',
+ 'h1',
+ 'h2',
+ 'h3',
+ 'h4',
+ 'h5',
+ 'h6',
+ 'blockquote',
+ 'pre',
+ 'address'
+ ];
+ var isList = function (universe, item) {
+ var tagName = universe.property().name(item);
+ return contains([
+ 'ol',
+ 'ul'
+ ], tagName);
+ };
+ var isBlock = function (universe, item) {
+ var tagName = universe.property().name(item);
+ return contains(blockList, tagName);
+ };
+ var isFormatting = function (universe, item) {
+ var tagName = universe.property().name(item);
+ return contains([
+ 'address',
+ 'pre',
+ 'p',
+ 'h1',
+ 'h2',
+ 'h3',
+ 'h4',
+ 'h5',
+ 'h6'
+ ], tagName);
+ };
+ var isHeading = function (universe, item) {
+ var tagName = universe.property().name(item);
+ return contains([
+ 'h1',
+ 'h2',
+ 'h3',
+ 'h4',
+ 'h5',
+ 'h6'
+ ], tagName);
+ };
+ var isContainer = function (universe, item) {
+ return contains([
+ 'div',
+ 'li',
+ 'td',
+ 'th',
+ 'blockquote',
+ 'body',
+ 'caption'
+ ], universe.property().name(item));
+ };
+ var isEmptyTag = function (universe, item) {
+ return contains([
+ 'br',
+ 'img',
+ 'hr',
+ 'input'
+ ], universe.property().name(item));
+ };
+ var isFrame = function (universe, item) {
+ return universe.property().name(item) === 'iframe';
+ };
+ var isInline = function (universe, item) {
+ return !(isBlock(universe, item) || isEmptyTag(universe, item)) && universe.property().name(item) !== 'li';
+ };
+ var Structure = {
+ isBlock: isBlock,
+ isList: isList,
+ isFormatting: isFormatting,
+ isHeading: isHeading,
+ isContainer: isContainer,
+ isEmptyTag: isEmptyTag,
+ isFrame: isFrame,
+ isInline: isInline
+ };
+
+ var universe$1 = DomUniverse();
+ var isBlock$1 = function (element) {
+ return Structure.isBlock(universe$1, element);
+ };
+ var isList$1 = function (element) {
+ return Structure.isList(universe$1, element);
+ };
+ var isFormatting$1 = function (element) {
+ return Structure.isFormatting(universe$1, element);
+ };
+ var isHeading$1 = function (element) {
+ return Structure.isHeading(universe$1, element);
+ };
+ var isContainer$1 = function (element) {
+ return Structure.isContainer(universe$1, element);
+ };
+ var isEmptyTag$1 = function (element) {
+ return Structure.isEmptyTag(universe$1, element);
+ };
+ var isFrame$1 = function (element) {
+ return Structure.isFrame(universe$1, element);
+ };
+ var isInline$1 = function (element) {
+ return Structure.isInline(universe$1, element);
+ };
+ var DomStructure = {
+ isBlock: isBlock$1,
+ isList: isList$1,
+ isFormatting: isFormatting$1,
+ isHeading: isHeading$1,
+ isContainer: isContainer$1,
+ isEmptyTag: isEmptyTag$1,
+ isFrame: isFrame$1,
+ isInline: isInline$1
+ };
+
+ var merge$3 = function (cells) {
+ var isBr = function (el) {
+ return name(el) === 'br';
+ };
+ var advancedBr = function (children) {
+ return forall(children, function (c) {
+ return isBr(c) || isText(c) && get$2(c).trim().length === 0;
+ });
+ };
+ var isListItem = function (el) {
+ return name(el) === 'li' || ancestor(el, DomStructure.isList).isSome();
+ };
+ var siblingIsBlock = function (el) {
+ return nextSibling(el).map(function (rightSibling) {
+ if (DomStructure.isBlock(rightSibling)) {
+ return true;
+ }
+ if (DomStructure.isEmptyTag(rightSibling)) {
+ return name(rightSibling) === 'img' ? false : true;
+ }
+ }).getOr(false);
+ };
+ var markCell = function (cell) {
+ return last$1(cell).bind(function (rightEdge) {
+ var rightSiblingIsBlock = siblingIsBlock(rightEdge);
+ return parent(rightEdge).map(function (parent) {
+ return rightSiblingIsBlock === true || isListItem(parent) || isBr(rightEdge) || DomStructure.isBlock(parent) && !eq(cell, parent) ? [] : [Element.fromTag('br')];
+ });
+ }).getOr([]);
+ };
+ var markContent = function () {
+ var content = bind(cells, function (cell) {
+ var children$1 = children(cell);
+ return advancedBr(children$1) ? [] : children$1.concat(markCell(cell));
+ });
+ return content.length === 0 ? [Element.fromTag('br')] : content;
+ };
+ var contents = markContent();
+ empty(cells[0]);
+ append$1(cells[0], contents);
+ };
+ var TableContent = { merge: merge$3 };
+
var prune = function (table) {
var cells = TableLookup.cells(table);
- if (cells.length === 0)
+ if (cells.length === 0) {
remove$2(table);
+ }
};
var outcome = Immutable('grid', 'cursor');
var elementFromGrid = function (grid, row, column) {
@@ -4700,8 +4860,8 @@
var example = details[0].row();
var targetIndex = details[0].row();
var rows = uniqueRows(details);
- var newGrid = foldl(rows, function (newGrid, _row) {
- return ModificationOperations.insertRowAt(newGrid, targetIndex, example, comparator, genWrappers.getOrInit);
+ var newGrid = foldl(rows, function (newG, _row) {
+ return ModificationOperations.insertRowAt(newG, targetIndex, example, comparator, genWrappers.getOrInit);
}, grid);
return bundle(newGrid, targetIndex, details[0].column());
};
@@ -4715,8 +4875,8 @@
var rows = uniqueRows(details);
var example = rows[rows.length - 1].row();
var targetIndex = rows[rows.length - 1].row() + rows[rows.length - 1].rowspan();
- var newGrid = foldl(rows, function (newGrid, _row) {
- return ModificationOperations.insertRowAt(newGrid, targetIndex, example, comparator, genWrappers.getOrInit);
+ var newGrid = foldl(rows, function (newG, _row) {
+ return ModificationOperations.insertRowAt(newG, targetIndex, example, comparator, genWrappers.getOrInit);
}, grid);
return bundle(newGrid, targetIndex, details[0].column());
};
@@ -4730,8 +4890,8 @@
var columns = uniqueColumns(details);
var example = columns[0].column();
var targetIndex = columns[0].column();
- var newGrid = foldl(columns, function (newGrid, _row) {
- return ModificationOperations.insertColumnAt(newGrid, targetIndex, example, comparator, genWrappers.getOrInit);
+ var newGrid = foldl(columns, function (newG, _row) {
+ return ModificationOperations.insertColumnAt(newG, targetIndex, example, comparator, genWrappers.getOrInit);
}, grid);
return bundle(newGrid, details[0].row(), targetIndex);
};
@@ -4745,8 +4905,8 @@
var example = details[details.length - 1].column();
var targetIndex = details[details.length - 1].column() + details[details.length - 1].colspan();
var columns = uniqueColumns(details);
- var newGrid = foldl(columns, function (newGrid, _row) {
- return ModificationOperations.insertColumnAt(newGrid, targetIndex, example, comparator, genWrappers.getOrInit);
+ var newGrid = foldl(columns, function (newG, _row) {
+ return ModificationOperations.insertColumnAt(newG, targetIndex, example, comparator, genWrappers.getOrInit);
}, grid);
return bundle(newGrid, details[0].row(), targetIndex);
};
@@ -4798,7 +4958,7 @@
}, grid);
return outcome(newGrid, Option.from(unmergable[0]));
};
- var pasteCells = function (grid, pasteDetails, comparator, genWrappers) {
+ var pasteCells = function (grid, pasteDetails, comparator, _genWrappers) {
var gridify = function (table, generators) {
var list = DetailsList.fromTable(table);
var wh = Warehouse.generate(list);
@@ -4819,7 +4979,7 @@
var wh = Warehouse.generate(pasteDetails);
return Transitions.toGrid(wh, generators, true);
};
- var pasteRowsBefore = function (grid, pasteDetails, comparator, genWrappers) {
+ var pasteRowsBefore = function (grid, pasteDetails, comparator, _genWrappers) {
var example = grid[pasteDetails.cells[0].row()];
var index = pasteDetails.cells[0].row();
var gridB = gridifyRows(pasteDetails.clipboard(), pasteDetails.generators(), example);
@@ -4827,7 +4987,7 @@
var cursor = elementFromGrid(mergedGrid, pasteDetails.cells[0].row(), pasteDetails.cells[0].column());
return outcome(mergedGrid, cursor);
};
- var pasteRowsAfter = function (grid, pasteDetails, comparator, genWrappers) {
+ var pasteRowsAfter = function (grid, pasteDetails, comparator, _genWrappers) {
var example = grid[pasteDetails.cells[0].row()];
var index = pasteDetails.cells[pasteDetails.cells.length - 1].row() + pasteDetails.cells[pasteDetails.cells.length - 1].rowspan();
var gridB = gridifyRows(pasteDetails.clipboard(), pasteDetails.generators(), example);
@@ -4835,6 +4995,23 @@
var cursor = elementFromGrid(mergedGrid, pasteDetails.cells[0].row(), pasteDetails.cells[0].column());
return outcome(mergedGrid, cursor);
};
+ var sortRows = function (grid, detail, sortComparator, ascending) {
+ var newGrid = TransformOperations.sortTableRows(grid, detail.column(), sortComparator, ascending);
+ return bundle(newGrid, detail.row(), detail.column());
+ };
+ var sortColumns = function (grid, detail, sortComparator, ascending) {
+ var newGrid = TransformOperations.sortTableColumns(grid, detail.row(), sortComparator, ascending);
+ return bundle(newGrid, detail.row(), detail.column());
+ };
+ var runSort = function (sortF) {
+ return function (wire, table, target, generators, direction, sortComparator, ascending) {
+ var operation = function (grid, detail, _comparator, _generators) {
+ return sortF(grid, detail, sortComparator, ascending);
+ };
+ var wrappedOperation = RunOperation.run(operation, RunOperation.onCell, noop, noop, Generators.modification);
+ return wrappedOperation(wire, table, target, generators, direction);
+ };
+ };
var resize = Adjustments.adjustWidthTo;
var TableOperations = {
insertRowBefore: RunOperation.run(insertRowBefore, RunOperation.onCell, noop, noop, Generators.modification),
@@ -4845,7 +5022,7 @@
insertColumnsBefore: RunOperation.run(insertColumnsBefore, RunOperation.onCells, resize, noop, Generators.modification),
insertColumnAfter: RunOperation.run(insertColumnAfter, RunOperation.onCell, resize, noop, Generators.modification),
insertColumnsAfter: RunOperation.run(insertColumnsAfter, RunOperation.onCells, resize, noop, Generators.modification),
- splitCellIntoColumns: RunOperation.run(splitCellIntoColumns$1, RunOperation.onCell, noop, noop, Generators.modification),
+ splitCellIntoColumns: RunOperation.run(splitCellIntoColumns$1, RunOperation.onCell, resize, noop, Generators.modification),
splitCellIntoRows: RunOperation.run(splitCellIntoRows$1, RunOperation.onCell, noop, noop, Generators.modification),
eraseColumns: RunOperation.run(eraseColumns, RunOperation.onCells, resize, prune, Generators.modification),
eraseRows: RunOperation.run(eraseRows, RunOperation.onCells, noop, prune, Generators.modification),
@@ -4854,14 +5031,16 @@
makeRowHeader: RunOperation.run(makeRowHeader, RunOperation.onCell, noop, noop, Generators.transform('col', 'th')),
unmakeRowHeader: RunOperation.run(unmakeRowHeader, RunOperation.onCell, noop, noop, Generators.transform(null, 'td')),
mergeCells: RunOperation.run(mergeCells, RunOperation.onMergable, noop, noop, Generators.merging),
- unmergeCells: RunOperation.run(unmergeCells, RunOperation.onUnmergable, noop, noop, Generators.merging),
+ unmergeCells: RunOperation.run(unmergeCells, RunOperation.onUnmergable, resize, noop, Generators.merging),
pasteCells: RunOperation.run(pasteCells, RunOperation.onPaste, resize, noop, Generators.modification),
pasteRowsBefore: RunOperation.run(pasteRowsBefore, RunOperation.onPasteRows, noop, noop, Generators.modification),
- pasteRowsAfter: RunOperation.run(pasteRowsAfter, RunOperation.onPasteRows, noop, noop, Generators.modification)
+ pasteRowsAfter: RunOperation.run(pasteRowsAfter, RunOperation.onPasteRows, noop, noop, Generators.modification),
+ sortRows: runSort(sortRows),
+ sortColumns: runSort(sortColumns)
};
var getBody$1 = function (editor) {
- return Element$$1.fromDom(editor.getBody());
+ return Element.fromDom(editor.getBody());
};
var getPixelWidth$1 = function (elm) {
return elm.getBoundingClientRect().width;
@@ -4892,7 +5071,7 @@
};
var getDirection = function (element) {
- return get$2(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
+ return get$1(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
};
var ltr$1 = { isRtl: constant(false) };
@@ -5030,7 +5209,7 @@
return function (table, target) {
removeDataStyle(table);
var wire = lazyWire();
- var doc = Element$$1.fromDom(editor.getDoc());
+ var doc = Element.fromDom(editor.getDoc());
var direction = TableDirection(Direction.directionAt);
var generators = TableFill.cellOperations(mutate, doc, cloneFormats);
return guard(table) ? operation(wire, table, target, generators, direction).bind(function (result) {
@@ -5156,7 +5335,7 @@
return appendItems(inputList, startItems || []);
};
function styleFieldHasFocus(e) {
- return e.control.rootControl.find('#style')[0].getEl().isEqualNode(document.activeElement);
+ return e.control.rootControl.find('#style')[0].getEl().isEqualNode(domGlobals.document.activeElement);
}
var syncAdvancedStyleFields = function (editor, evt) {
if (styleFieldHasFocus(evt)) {
@@ -5805,25 +5984,25 @@
var DefaultRenderOptions = {
styles: {
'border-collapse': 'collapse',
- width: '100%'
+ 'width': '100%'
},
attributes: { border: '1' },
percentages: true
};
var makeTable = function () {
- return Element$$1.fromTag('table');
+ return Element.fromTag('table');
};
var tableBody = function () {
- return Element$$1.fromTag('tbody');
+ return Element.fromTag('tbody');
};
var tableRow = function () {
- return Element$$1.fromTag('tr');
+ return Element.fromTag('tr');
};
var tableHeaderCell = function () {
- return Element$$1.fromTag('th');
+ return Element.fromTag('th');
};
var tableCell = function () {
- return Element$$1.fromTag('td');
+ return Element.fromTag('td');
};
var render$1 = function (rows, columns, rowHeaders, columnHeaders, renderOpts) {
if (renderOpts === void 0) {
@@ -5845,7 +6024,7 @@
if (i < rowHeaders) {
set(td, 'scope', 'col');
}
- append(td, Element$$1.fromTag('br'));
+ append(td, Element.fromTag('br'));
if (renderOpts.percentages) {
set$1(td, 'width', 100 / columns + '%');
}
@@ -5861,8 +6040,8 @@
return element.dom().innerHTML;
};
var getOuter$2 = function (element) {
- var container = Element$$1.fromTag('div');
- var clone = Element$$1.fromDom(element.dom().cloneNode(true));
+ var container = Element.fromTag('div');
+ var clone = Element.fromDom(element.dom().cloneNode(true));
append(container, clone);
return get$8(container);
};
@@ -5898,7 +6077,7 @@
editor.insertContent(html);
return descendant$1(getBody$1(editor), 'table[data-mce-id="__mce"]').map(function (table) {
if (isPixelsForced(editor)) {
- set$1(table, 'width', get$2(table, 'width'));
+ set$1(table, 'width', get$1(table, 'width'));
}
remove(table, 'data-mce-id');
fireEvents(editor, table);
@@ -6176,10 +6355,10 @@
var registerCommands = function (editor, actions, cellSelection, selections, clipboardRows) {
var isRoot = getIsRoot(editor);
var eraseTable = function () {
- var cell = Element$$1.fromDom(editor.dom.getParent(editor.selection.getStart(), 'th,td'));
- var table = TableLookup.table(cell, isRoot);
+ getSelectionStartCell().orThunk(getSelectionStartCaption).each(function (cellOrCaption) {
+ var table = TableLookup.table(cellOrCaption, isRoot);
table.filter(not(isRoot)).each(function (table) {
- var cursor = Element$$1.fromText('');
+ var cursor = Element.fromText('');
after(table, cursor);
remove$2(table);
var rng = editor.dom.createRng();
@@ -6187,10 +6366,15 @@
rng.setEnd(cursor.dom(), 0);
editor.selection.setRng(rng);
});
+ });
+ };
+ var getSelectionStartFromSelector = function (selector) {
+ return function () {
+ return Option.from(editor.dom.getParent(editor.selection.getStart(), selector)).map(Element.fromDom);
};
- var getSelectionStartCell = function () {
- return Element$$1.fromDom(editor.dom.getParent(editor.selection.getStart(), 'th,td'));
};
+ var getSelectionStartCaption = getSelectionStartFromSelector('caption');
+ var getSelectionStartCell = getSelectionStartFromSelector('th,td');
var getTableFromCell = function (cell) {
return TableLookup.table(cell, isRoot);
};
@@ -6208,9 +6392,8 @@
}
};
var actOnSelection = function (execute) {
- var cell = getSelectionStartCell();
- var table = getTableFromCell(cell);
- table.each(function (table) {
+ getSelectionStartCell().each(function (cell) {
+ getTableFromCell(cell).each(function (table) {
var targets = TableTargets.forMenu(selections, table, cell);
var beforeSize = getSize(table);
execute(table, targets).each(function (rng) {
@@ -6221,26 +6404,26 @@
removeDataStyle(table);
});
});
+ });
};
var copyRowSelection = function (execute) {
- var cell = getSelectionStartCell();
- var table = getTableFromCell(cell);
- return table.bind(function (table) {
- var doc = Element$$1.fromDom(editor.getDoc());
+ return getSelectionStartCell().bind(function (cell) {
+ return getTableFromCell(cell).bind(function (table) {
+ var doc = Element.fromDom(editor.getDoc());
var targets = TableTargets.forMenu(selections, table, cell);
var generators = TableFill.cellOperations(noop, doc, Option.none());
return CopyRows.copyRows(table, targets, generators);
});
+ });
};
var pasteOnSelection = function (execute) {
clipboardRows.get().each(function (rows) {
var clonedRows = map(rows, function (row) {
return deep(row);
});
- var cell = getSelectionStartCell();
- var table = getTableFromCell(cell);
- table.bind(function (table) {
- var doc = Element$$1.fromDom(editor.getDoc());
+ getSelectionStartCell().each(function (cell) {
+ getTableFromCell(cell).each(function (table) {
+ var doc = Element.fromDom(editor.getDoc());
var generators = TableFill.paste(doc);
var targets = TableTargets.pasteRows(selections, table, cell, clonedRows, generators);
execute(table, targets).each(function (rng) {
@@ -6250,6 +6433,7 @@
});
});
});
+ });
};
each$3({
mceTableSplitCells: function () {
@@ -6307,7 +6491,7 @@
var Commands = { registerCommands: registerCommands };
var only$1 = function (element) {
- var parent = Option.from(element.dom().documentElement).map(Element$$1.fromDom).getOr(element);
+ var parent = Option.from(element.dom().documentElement).map(Element.fromDom).getOr(element);
return {
parent: constant(parent),
view: constant(element),
@@ -6338,7 +6522,7 @@
function Event (fields) {
var struct = Immutable.apply(null, fields);
var handlers = [];
- var bind$$1 = function (handler) {
+ var bind = function (handler) {
if (handler === undefined) {
throw 'Event bind error: undefined handler';
}
@@ -6356,7 +6540,7 @@
});
};
return {
- bind: bind$$1,
+ bind: bind,
unbind: unbind,
trigger: trigger
};
@@ -6407,8 +6591,8 @@
var Styles$2 = { resolve: styles$1.resolve };
function Blocker (options) {
- var settings = merge$1({ 'layerClass': Styles$2.resolve('blocker') }, options);
- var div = Element$$1.fromTag('div');
+ var settings = merge({ 'layerClass': Styles$2.resolve('blocker') }, options);
+ var div = Element.fromTag('div');
set(div, 'role', 'presentation');
setAll$1(div, {
position: 'fixed',
@@ -6433,20 +6617,21 @@
var mkEvent = function (target, x, y, stop, prevent, kill, raw) {
return {
- 'target': constant(target),
- 'x': constant(x),
- 'y': constant(y),
- 'stop': stop,
- 'prevent': prevent,
- 'kill': kill,
- 'raw': constant(raw)
+ target: constant(target),
+ x: constant(x),
+ y: constant(y),
+ stop: stop,
+ prevent: prevent,
+ kill: kill,
+ raw: constant(raw)
};
};
var handle = function (filter, handler) {
return function (rawEvent) {
- if (!filter(rawEvent))
+ if (!filter(rawEvent)) {
return;
- var target = Element$$1.fromDom(rawEvent.target);
+ }
+ var target = Element.fromDom(rawEvent.target);
var stop = function () {
rawEvent.stopPropagation();
};
@@ -6481,7 +6666,7 @@
var extract$1 = function (event) {
return Option.some(Position(event.x(), event.y()));
};
- var mutate$1 = function (mutation, info) {
+ var mutate = function (mutation, info) {
mutation.mutate(info.left(), info.top());
};
var sink$1 = function (dragApi, settings) {
@@ -6514,7 +6699,7 @@
compare: compare,
extract: extract$1,
sink: sink$1,
- mutate: mutate$1
+ mutate: mutate
});
function InDrag () {
@@ -6582,11 +6767,11 @@
};
}
- var last$3 = function (fn, rate) {
+ var last$2 = function (fn, rate) {
var timer = null;
var cancel = function () {
if (timer !== null) {
- clearTimeout(timer);
+ domGlobals.clearTimeout(timer);
timer = null;
}
};
@@ -6596,8 +6781,8 @@
args[_i] = arguments[_i];
}
if (timer !== null)
- clearTimeout(timer);
- timer = setTimeout(function () {
+ domGlobals.clearTimeout(timer);
+ timer = domGlobals.setTimeout(function () {
fn.apply(null, args);
timer = null;
}, rate);
@@ -6622,7 +6807,7 @@
events.trigger.stop();
}
};
- var throttledDrop = last$3(drop, 200);
+ var throttledDrop = last$2(drop, 200);
var go = function (parent) {
sink.start(parent);
movement.on();
@@ -6676,9 +6861,13 @@
};
var Dragger = { transform: transform$1 };
+ var closest$2 = function (scope, selector, isRoot) {
+ return closest$1(scope, selector, isRoot).isSome();
+ };
+
function Mutation () {
var events = Events.create({
- 'drag': Event([
+ drag: Event([
'xDelta',
'yDelta'
])
@@ -6721,17 +6910,13 @@
};
}
- var closest$2 = function (scope, selector, isRoot) {
- return closest$1(scope, selector, isRoot).isSome();
- };
-
var resizeBarDragging = Styles.resolve('resizer-bar-dragging');
function BarManager (wire, direction, hdirection) {
var mutation = BarMutation();
var resizing = Dragger.transform(mutation, {});
var hoverTable = Option.none();
- var getResizer = function (element, type$$1) {
- return Option.from(get$1(element, type$$1));
+ var getResizer = function (element, type) {
+ return Option.from(get(element, type));
};
mutation.events.drag.bind(function (event) {
getResizer(event.target(), 'data-row').each(function (_dataRow) {
@@ -6743,9 +6928,9 @@
set$1(event.target(), 'left', currentCol + event.xDelta() + 'px');
});
});
- var getDelta = function (target, direction) {
- var newX = CellUtils.getInt(target, direction);
- var oldX = parseInt(get$1(target, 'data-initial-' + direction), 10);
+ var getDelta = function (target, dir) {
+ var newX = CellUtils.getInt(target, dir);
+ var oldX = parseInt(get(target, 'data-initial-' + dir), 10);
return newX - oldX;
};
resizing.events.stop.bind(function () {
@@ -6765,19 +6950,21 @@
});
});
});
- var handler = function (target, direction) {
+ var handler = function (target, dir) {
events.trigger.startAdjust();
mutation.assign(target);
- set(target, 'data-initial-' + direction, parseInt(get$2(target, direction), 10));
+ set(target, 'data-initial-' + dir, parseInt(get$1(target, dir), 10));
add$2(target, resizeBarDragging);
set$1(target, 'opacity', '0.2');
resizing.go(wire.parent());
};
var mousedown = bind$2(wire.parent(), 'mousedown', function (event) {
- if (Bars.isRowBar(event.target()))
+ if (Bars.isRowBar(event.target())) {
handler(event.target(), 'top');
- if (Bars.isColBar(event.target()))
+ }
+ if (Bars.isColBar(event.target())) {
handler(event.target(), 'left');
+ }
});
var isRoot = function (e) {
return eq(e, wire.view());
@@ -6835,7 +7022,7 @@
});
manager.events.adjustHeight.bind(function (event) {
events.trigger.beforeResize(event.table());
- var delta = hdirection.delta(event.delta(), event.table());
+ var delta = hdirection.delta(event.delta());
Adjustments.adjustHeight(event.table(), delta, event.row(), hdirection);
events.trigger.afterResize(event.table());
});
@@ -6859,7 +7046,7 @@
}
var createContainer = function () {
- var container = Element$$1.fromTag('div');
+ var container = Element.fromTag('div');
setAll$1(container, {
position: 'static',
height: '0',
@@ -6872,7 +7059,7 @@
return container;
};
var get$9 = function (editor, container) {
- return editor.inline ? ResizeWire.body(getBody$1(editor), createContainer()) : ResizeWire.only(Element$$1.fromDom(editor.getDoc()));
+ return editor.inline ? ResizeWire.body(getBody$1(editor), createContainer()) : ResizeWire.only(Element.fromDom(editor.getDoc()));
};
var remove$6 = function (editor, wire) {
if (editor.inline) {
@@ -6900,7 +7087,7 @@
return resize;
};
var lazyWire = function () {
- return wire.getOr(ResizeWire.only(Element$$1.fromDom(editor.getBody())));
+ return wire.getOr(ResizeWire.only(Element.fromDom(editor.getBody())));
};
var destroy = function () {
resize.each(function (sz) {
@@ -6978,12 +7165,15 @@
};
};
+ var folder$1 = function (fold) {
+ return { fold: fold };
+ };
var none$2 = function (current) {
return folder$1(function (n, f, m, l) {
return n(current);
});
};
- var first$5 = function (current) {
+ var first$1 = function (current) {
return folder$1(function (n, f, m, l) {
return f(current);
});
@@ -6993,19 +7183,16 @@
return m(current, target);
});
};
- var last$4 = function (current) {
+ var last$3 = function (current) {
return folder$1(function (n, f, m, l) {
return l(current);
});
};
- var folder$1 = function (fold) {
- return { fold: fold };
- };
var CellLocation = {
none: none$2,
- first: first$5,
+ first: first$1,
middle: middle$1,
- last: last$4
+ last: last$3
};
var detect$4 = function (current, isRoot) {
@@ -7044,9 +7231,9 @@
};
var adt = Adt.generate([
- { 'before': ['element'] },
+ { before: ['element'] },
{
- 'on': [
+ on: [
'element',
'offset'
]
@@ -7087,11 +7274,11 @@
]
}
]);
- var range$2 = Immutable('start', 'soffset', 'finish', 'foffset');
+ var range$1 = Immutable('start', 'soffset', 'finish', 'foffset');
var getStart$1 = function (selection) {
return selection.match({
domRange: function (rng) {
- return Element$$1.fromDom(rng.startContainer);
+ return Element.fromDom(rng.startContainer);
},
relative: function (startSitu, finishSitu) {
return Situ.getStart(startSitu);
@@ -7105,7 +7292,7 @@
var start = getStart$1(selection);
return defaultView(start);
};
- var relative$1 = type$2.relative;
+ var relative = type$2.relative;
var exact = type$2.exact;
var makeRange = function (start, soffset, finish, foffset) {
@@ -7194,7 +7381,7 @@
}
]);
var fromRange = function (win, type, range) {
- return type(Element$$1.fromDom(range.startContainer), range.startOffset, Element$$1.fromDom(range.endContainer), range.endOffset);
+ return type(Element.fromDom(range.startContainer), range.startOffset, Element.fromDom(range.endContainer), range.endOffset);
};
var getRanges = function (win, selection) {
return selection.match({
@@ -7233,7 +7420,7 @@
return rev.collapsed === false;
});
return reversed.map(function (rev) {
- return adt$1.rtl(Element$$1.fromDom(rev.endContainer), rev.endOffset, Element$$1.fromDom(rev.startContainer), rev.startOffset);
+ return adt$1.rtl(Element.fromDom(rev.endContainer), rev.endOffset, Element.fromDom(rev.startContainer), rev.startOffset);
}).getOrThunk(function () {
return fromRange(win, adt$1.ltr, rng);
});
@@ -7264,10 +7451,11 @@
};
var searchForPoint = function (rectForOffset, x, y, maxX, length) {
- if (length === 0)
+ if (length === 0) {
return 0;
- else if (x === maxX)
+ } else if (x === maxX) {
return length - 1;
+ }
var xDelta = maxX;
for (var i = 1; i < length; i++) {
var rect = rectForOffset(i);
@@ -7287,17 +7475,17 @@
};
var locateOffset = function (doc, textnode, x, y, rect) {
- var rangeForOffset = function (offset) {
+ var rangeForOffset = function (o) {
var r = doc.dom().createRange();
- r.setStart(textnode.dom(), offset);
+ r.setStart(textnode.dom(), o);
r.collapse(true);
return r;
};
- var rectForOffset = function (offset) {
- var r = rangeForOffset(offset);
+ var rectForOffset = function (o) {
+ var r = rangeForOffset(o);
return r.getBoundingClientRect();
};
- var length = get$3(textnode).length;
+ var length = get$2(textnode).length;
var offset = searchForPoint(rectForOffset, x, y, rect.right, length);
return rangeForOffset(offset);
};
@@ -7350,7 +7538,7 @@
cursorRange.selectNode(node.dom());
var rect = cursorRange.getBoundingClientRect();
var collapseDirection = getCollapseDirection(rect, x);
- var f = collapseDirection === COLLAPSE_TO_LEFT ? first$3 : last$2;
+ var f = collapseDirection === COLLAPSE_TO_LEFT ? first : last$1;
return f(node).map(function (target) {
return createCollapsedNode(doc, target, collapseDirection);
});
@@ -7367,8 +7555,9 @@
var caretPositionFromPoint = function (doc, x, y) {
return Option.from(doc.dom().caretPositionFromPoint(x, y)).bind(function (pos) {
- if (pos.offsetNode === null)
+ if (pos.offsetNode === null) {
return Option.none();
+ }
var r = doc.dom().createRange();
r.setStart(pos.offsetNode, pos.offset);
r.collapse();
@@ -7387,7 +7576,7 @@
return locate$1(doc, node, boundedX, boundedY);
};
var searchFromPoint = function (doc, x, y) {
- return Element$$1.fromPoint(doc, x, y).bind(function (elem) {
+ return Element.fromPoint(doc, x, y).bind(function (elem) {
var fallback = function () {
return search(doc, elem, x);
};
@@ -7396,39 +7585,40 @@
};
var availableSearch = document.caretPositionFromPoint ? caretPositionFromPoint : document.caretRangeFromPoint ? caretRangeFromPoint : searchFromPoint;
var fromPoint$1 = function (win, x, y) {
- var doc = Element$$1.fromDom(win.document);
+ var doc = Element.fromDom(win.document);
return availableSearch(doc, x, y).map(function (rng) {
- return range$2(Element$$1.fromDom(rng.startContainer), rng.startOffset, Element$$1.fromDom(rng.endContainer), rng.endOffset);
+ return range$1(Element.fromDom(rng.startContainer), rng.startOffset, Element.fromDom(rng.endContainer), rng.endOffset);
});
};
var beforeSpecial = function (element, offset) {
- var name$$1 = name(element);
- if ('input' === name$$1)
+ var name$1 = name(element);
+ if ('input' === name$1) {
return Situ.after(element);
- else if (!contains([
+ } else if (!contains([
'br',
'img'
- ], name$$1))
+ ], name$1)) {
return Situ.on(element, offset);
- else
+ } else {
return offset === 0 ? Situ.before(element) : Situ.after(element);
+ }
};
var preprocessRelative = function (startSitu, finishSitu) {
var start = startSitu.fold(Situ.before, beforeSpecial, Situ.after);
var finish = finishSitu.fold(Situ.before, beforeSpecial, Situ.after);
- return relative$1(start, finish);
+ return relative(start, finish);
};
var preprocessExact = function (start, soffset, finish, foffset) {
var startSitu = beforeSpecial(start, soffset);
var finishSitu = beforeSpecial(finish, foffset);
- return relative$1(startSitu, finishSitu);
+ return relative(startSitu, finishSitu);
};
var preprocess = function (selection) {
return selection.match({
domRange: function (rng) {
- var start = Element$$1.fromDom(rng.startContainer);
- var finish = Element$$1.fromDom(rng.endContainer);
+ var start = Element.fromDom(rng.startContainer);
+ var finish = Element.fromDom(rng.endContainer);
return preprocessExact(start, rng.startOffset, finish, rng.endOffset);
},
relative: preprocessRelative,
@@ -7494,15 +7684,15 @@
if (selection.rangeCount > 0) {
var firstRng = selection.getRangeAt(0);
var lastRng = selection.getRangeAt(selection.rangeCount - 1);
- return Option.some(range$2(Element$$1.fromDom(firstRng.startContainer), firstRng.startOffset, Element$$1.fromDom(lastRng.endContainer), lastRng.endOffset));
+ return Option.some(range$1(Element.fromDom(firstRng.startContainer), firstRng.startOffset, Element.fromDom(lastRng.endContainer), lastRng.endOffset));
} else {
return Option.none();
}
};
var doGetExact = function (selection) {
- var anchorNode = Element$$1.fromDom(selection.anchorNode);
- var focusNode = Element$$1.fromDom(selection.focusNode);
- return after$3(anchorNode, selection.anchorOffset, focusNode, selection.focusOffset) ? Option.some(range$2(Element$$1.fromDom(selection.anchorNode), selection.anchorOffset, Element$$1.fromDom(selection.focusNode), selection.focusOffset)) : readRange(selection);
+ var anchor = Element.fromDom(selection.anchorNode);
+ var focus = Element.fromDom(selection.focusNode);
+ return after$3(anchor, selection.anchorOffset, focus, selection.focusOffset) ? Option.some(range$1(anchor, selection.anchorOffset, focus, selection.focusOffset)) : readRange(selection);
};
var setToElement = function (win, element) {
var rng = selectNodeContents(win, element);
@@ -7544,15 +7734,15 @@
};
var getNewRowCursorPosition = function (editor, table) {
var rows = descendants$1(table, 'tr');
- return last(rows).bind(function (last$$1) {
- return descendant$1(last$$1, 'td,th').map(function (first) {
+ return last(rows).bind(function (last) {
+ return descendant$1(last, 'td,th').map(function (first) {
return getCellFirstCursorPosition(editor, first);
});
});
};
var go = function (editor, isRoot, cell, actions, lazyWire) {
return cell.fold(Option.none, Option.none, function (current, next) {
- return first$3(next).map(function (cell) {
+ return first(next).map(function (cell) {
return getCellFirstCursorPosition(editor, cell);
});
}, function (current) {
@@ -7574,18 +7764,18 @@
if (event.keyCode === global$3.TAB) {
var body_1 = getBody$1(editor);
var isRoot_1 = function (element) {
- var name$$1 = name(element);
- return eq(element, body_1) || contains(rootElements, name$$1);
+ var name$1 = name(element);
+ return eq(element, body_1) || contains(rootElements, name$1);
};
var rng = editor.selection.getRng();
if (rng.collapsed) {
- var start = Element$$1.fromDom(rng.startContainer);
+ var start = Element.fromDom(rng.startContainer);
TableLookup.cell(start, isRoot_1).each(function (cell) {
event.preventDefault();
var navigation = event.shiftKey ? backward : forward;
var rng = navigation(editor, isRoot_1, cell, actions, lazyWire);
- rng.each(function (range$$1) {
- editor.selection.setRng(range$$1);
+ rng.each(function (range) {
+ editor.selection.setRng(range);
});
});
}
@@ -7623,9 +7813,9 @@
var convertToRange = function (win, selection) {
var rng = asLtrRange(win, selection);
return {
- start: constant(Element$$1.fromDom(rng.startContainer)),
+ start: constant(Element.fromDom(rng.startContainer)),
soffset: constant(rng.startOffset),
- finish: constant(Element$$1.fromDom(rng.endContainer)),
+ finish: constant(Element.fromDom(rng.endContainer)),
foffset: constant(rng.endOffset)
};
};
@@ -7641,21 +7831,21 @@
};
var isSafari = PlatformDetection$1.detect().browser.isSafari();
- var get$b = function (_doc) {
- var doc = _doc !== undefined ? _doc.dom() : document;
+ var get$b = function (_DOC) {
+ var doc = _DOC !== undefined ? _DOC.dom() : domGlobals.document;
var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
var y = doc.body.scrollTop || doc.documentElement.scrollTop;
return Position(x, y);
};
- var by = function (x, y, _doc) {
- var doc = _doc !== undefined ? _doc.dom() : document;
+ var by = function (x, y, _DOC) {
+ var doc = _DOC !== undefined ? _DOC.dom() : domGlobals.document;
var win = doc.defaultView;
win.scrollBy(x, y);
};
function WindowBridge (win) {
var elementFromPoint = function (x, y) {
- return Element$$1.fromPoint(Element$$1.fromDom(win.document), x, y);
+ return Element.fromPoint(Element.fromDom(win.document), x, y);
};
var getRect = function (element) {
return element.dom().getBoundingClientRect();
@@ -7672,14 +7862,14 @@
});
};
var fromSitus = function (situs) {
- var relative = relative$1(situs.start(), situs.finish());
- return Util$1.convertToRange(win, relative);
+ var relative$1 = relative(situs.start(), situs.finish());
+ return Util$1.convertToRange(win, relative$1);
};
var situsFromPoint = function (x, y) {
- return getAtPoint(win, x, y).map(function (exact$$1) {
+ return getAtPoint(win, x, y).map(function (exact) {
return {
- start: constant(Situ.on(exact$$1.start(), exact$$1.soffset())),
- finish: constant(Situ.on(exact$$1.finish(), exact$$1.foffset()))
+ start: constant(Situ.on(exact.start(), exact.soffset())),
+ finish: constant(Situ.on(exact.finish(), exact.foffset()))
};
});
};
@@ -7699,11 +7889,11 @@
return win.innerHeight;
};
var getScrollY = function () {
- var pos = get$b(Element$$1.fromDom(win.document));
+ var pos = get$b(Element.fromDom(win.document));
return pos.top();
};
var scrollBy = function (x, y) {
- by(x, y, Element$$1.fromDom(win.document));
+ by(x, y, Element.fromDom(win.document));
};
return {
elementFromPoint: elementFromPoint,
@@ -7816,7 +8006,7 @@
var getBottom = function (caret) {
return caret.bottom();
};
- var toString$1 = function (caret) {
+ var toString = function (caret) {
return '(' + caret.left() + ', ' + caret.top() + ') -> (' + caret.right() + ', ' + caret.bottom() + ')';
};
var Carets = {
@@ -7828,7 +8018,7 @@
getTop: getTop$1,
getBottom: getBottom,
translate: translate,
- toString: toString$1
+ toString: toString
};
var getPartialBox = function (bridge, element, offset) {
@@ -7871,20 +8061,26 @@
};
var traverse = Immutable('item', 'mode');
- var backtrack = function (universe, item, direction, _transition) {
- var transition = _transition !== undefined ? _transition : sidestep;
+ var backtrack = function (universe, item, _direction, transition) {
+ if (transition === void 0) {
+ transition = sidestep;
+ }
return universe.property().parent(item).map(function (p) {
return traverse(p, transition);
});
};
- var sidestep = function (universe, item, direction, _transition) {
- var transition = _transition !== undefined ? _transition : advance;
+ var sidestep = function (universe, item, direction, transition) {
+ if (transition === void 0) {
+ transition = advance;
+ }
return direction.sibling(universe, item).map(function (p) {
return traverse(p, transition);
});
};
- var advance = function (universe, item, direction, _transition) {
- var transition = _transition !== undefined ? _transition : advance;
+ var advance = function (universe, item, direction, transition) {
+ if (transition === void 0) {
+ transition = advance;
+ }
var children = universe.property().children(item);
var result = direction.first(children);
return result.map(function (r) {
@@ -7909,7 +8105,9 @@
}
];
var go$1 = function (universe, item, mode, direction, rules) {
- var rules = rules !== undefined ? rules : successors;
+ if (rules === void 0) {
+ rules = successors;
+ }
var ruleOpt = find(rules, function (succ) {
return succ.current === mode;
});
@@ -7921,12 +8119,6 @@
});
});
};
- var Walker = {
- backtrack: backtrack,
- sidestep: sidestep,
- advance: advance,
- go: go$1
- };
var left$1 = function () {
var sibling = function (universe, item) {
@@ -7958,7 +8150,7 @@
};
var hone = function (universe, item, predicate, mode, direction, isRoot) {
- var next = Walker.go(universe, item, mode, direction);
+ var next = go$1(universe, item, mode, direction);
return next.bind(function (n) {
if (isRoot(n.item()))
return Option.none();
@@ -7967,82 +8159,38 @@
});
};
var left$2 = function (universe, item, predicate, isRoot) {
- return hone(universe, item, predicate, Walker.sidestep, Walkers.left(), isRoot);
+ return hone(universe, item, predicate, sidestep, Walkers.left(), isRoot);
};
var right$2 = function (universe, item, predicate, isRoot) {
- return hone(universe, item, predicate, Walker.sidestep, Walkers.right(), isRoot);
- };
- var Seeker = {
- left: left$2,
- right: right$2
+ return hone(universe, item, predicate, sidestep, Walkers.right(), isRoot);
};
- var isLeaf = function (universe, element) {
+ var isLeaf = function (universe) {
+ return function (element) {
return universe.property().children(element).length === 0;
};
+ };
var before$3 = function (universe, item, isRoot) {
- return seekLeft(universe, item, curry(isLeaf, universe), isRoot);
+ return seekLeft(universe, item, isLeaf(universe), isRoot);
};
var after$4 = function (universe, item, isRoot) {
- return seekRight(universe, item, curry(isLeaf, universe), isRoot);
- };
- var seekLeft = function (universe, item, predicate, isRoot) {
- return Seeker.left(universe, item, predicate, isRoot);
- };
- var seekRight = function (universe, item, predicate, isRoot) {
- return Seeker.right(universe, item, predicate, isRoot);
- };
- var walkers = function () {
- return {
- left: Walkers.left,
- right: Walkers.right
- };
- };
- var walk = function (universe, item, mode, direction, _rules) {
- return Walker.go(universe, item, mode, direction, _rules);
- };
- var Gather = {
- before: before$3,
- after: after$4,
- seekLeft: seekLeft,
- seekRight: seekRight,
- walkers: walkers,
- walk: walk,
- backtrack: Walker.backtrack,
- sidestep: Walker.sidestep,
- advance: Walker.advance
+ return seekRight(universe, item, isLeaf(universe), isRoot);
};
+ var seekLeft = left$2;
+ var seekRight = right$2;
var universe$2 = DomUniverse();
- var gather = function (element, prune, transform) {
- return Gather.gather(universe$2, element, prune, transform);
- };
var before$4 = function (element, isRoot) {
- return Gather.before(universe$2, element, isRoot);
+ return before$3(universe$2, element, isRoot);
};
var after$5 = function (element, isRoot) {
- return Gather.after(universe$2, element, isRoot);
+ return after$4(universe$2, element, isRoot);
};
var seekLeft$1 = function (element, predicate, isRoot) {
- return Gather.seekLeft(universe$2, element, predicate, isRoot);
+ return seekLeft(universe$2, element, predicate, isRoot);
};
var seekRight$1 = function (element, predicate, isRoot) {
- return Gather.seekRight(universe$2, element, predicate, isRoot);
- };
- var walkers$1 = function () {
- return Gather.walkers();
- };
- var walk$1 = function (item, mode, direction, _rules) {
- return Gather.walk(universe$2, item, mode, direction, _rules);
- };
- var DomGather = {
- gather: gather,
- before: before$4,
- after: after$5,
- seekLeft: seekLeft$1,
- seekRight: seekRight$1,
- walkers: walkers$1,
- walk: walk$1
+ return seekRight(universe$2, element, predicate, isRoot);
};
var JUMP_SIZE = 5;
@@ -8087,13 +8235,13 @@
point: Carets.getTop,
adjuster: adjustUp,
move: Carets.moveUp,
- gather: DomGather.before
+ gather: before$4
};
var downMovement = {
point: Carets.getBottom,
adjuster: adjustDown,
move: Carets.moveDown,
- gather: DomGather.after
+ gather: after$5
};
var isAtTable = function (bridge, x, y) {
return bridge.elementFromPoint(x, y).filter(function (elm) {
@@ -8195,28 +8343,21 @@
var point = Immutable('element', 'offset');
var delta = Immutable('element', 'deltaOffset');
- var range$3 = Immutable('element', 'start', 'finish');
+ var range$2 = Immutable('element', 'start', 'finish');
var points = Immutable('begin', 'end');
var text = Immutable('element', 'text');
- var Spot = {
- point: point,
- delta: delta,
- range: range$3,
- points: points,
- text: text
- };
var inAncestor = Immutable('ancestor', 'descendants', 'element', 'index');
var inParent = Immutable('parent', 'children', 'element', 'index');
var indexInParent = function (element) {
- return parent(element).bind(function (parent$$1) {
- var children$$1 = children(parent$$1);
- return indexOf$1(children$$1, element).map(function (index) {
- return inParent(parent$$1, children$$1, element, index);
+ return parent(element).bind(function (parent) {
+ var children$1 = children(parent);
+ return indexOf(children$1, element).map(function (index) {
+ return inParent(parent, children$1, element, index);
});
});
};
- var indexOf$1 = function (elements, element) {
+ var indexOf = function (elements, element) {
return findIndex(elements, curry(eq, element));
};
@@ -8225,7 +8366,7 @@
};
var gatherer = function (cand, gather, isRoot) {
return gather(cand, isRoot).bind(function (target) {
- return isText(target) && get$3(target).trim().length === 0 ? gatherer(target, gather, isRoot) : Option.some(target);
+ return isText(target) && get$2(target).trim().length === 0 ? gatherer(target, gather, isRoot) : Option.some(target);
});
};
var handleBr = function (isRoot, element, direction) {
@@ -8264,9 +8405,9 @@
}, function () {
return Option.none();
}, function (cell) {
- return Option.some(Spot.point(cell, 0));
+ return Option.some(point(cell, 0));
}, function (cell) {
- return Option.some(Spot.point(cell, getEnd(cell)));
+ return Option.some(point(cell, getEnd(cell)));
});
};
var BrTags = {
@@ -8279,7 +8420,7 @@
var findSpot = function (bridge, isRoot, direction) {
return bridge.getSelection().bind(function (sel) {
return BrTags.tryBr(isRoot, sel.finish(), sel.foffset(), direction).fold(function () {
- return Option.some(Spot.point(sel.finish(), sel.foffset()));
+ return Option.some(point(sel.finish(), sel.foffset()));
}, function (brNeighbour) {
var range = bridge.fromSitus(brNeighbour);
var analysis = BeforeAfter.verify(bridge, sel.finish(), sel.foffset(), range.finish(), range.foffset(), direction.failure, isRoot);
@@ -8335,13 +8476,13 @@
};
var TableKeys = { handle: handle$2 };
- var ancestor$3 = function (scope, predicate, isRoot) {
+ var ancestor$2 = function (scope, predicate, isRoot) {
return ancestor(scope, predicate, isRoot).isSome();
};
var detection = PlatformDetection$1.detect();
var inSameTable = function (elem, table) {
- return ancestor$3(elem, function (e) {
+ return ancestor$2(elem, function (e) {
return parent(e).exists(function (p) {
return eq(p, table);
});
@@ -8381,8 +8522,8 @@
return closest$1(startRow, 'table', isRoot).bind(function (table) {
var rows = descendants$1(table, 'tr');
if (eq(startRow, rows[0])) {
- return DomGather.seekLeft(table, function (element) {
- return last$2(element).isSome();
+ return seekLeft$1(table, function (element) {
+ return last$1(element).isSome();
}, isRoot).map(function (last) {
var lastOffset = getEnd(last);
return Responses.response(Option.some(Util$1.makeSitus(last, lastOffset, last, lastOffset)), true);
@@ -8398,8 +8539,8 @@
return closest$1(startRow, 'table', isRoot).bind(function (table) {
var rows = descendants$1(table, 'tr');
if (eq(startRow, rows[rows.length - 1])) {
- return DomGather.seekRight(table, function (element) {
- return first$3(element).isSome();
+ return seekRight$1(table, function (element) {
+ return first(element).isSome();
}, isRoot).map(function (first) {
return Responses.response(Option.some(Util$1.makeSitus(first, 0, first, 0)), true);
});
@@ -8460,7 +8601,7 @@
var KeyDirection = {
down: {
traverse: nextSibling,
- gather: DomGather.after,
+ gather: after$5,
relative: Situ.before,
otherRetry: Retries.tryDown,
ieRetry: Retries.ieTryDown,
@@ -8468,7 +8609,7 @@
},
up: {
traverse: prevSibling,
- gather: DomGather.before,
+ gather: before$4,
relative: Situ.before,
otherRetry: Retries.tryUp,
ieRetry: Retries.ieTryUp,
@@ -8643,7 +8784,7 @@
};
var hasInternalTarget = function (e) {
- return has$2(Element$$1.fromDom(e.target), 'ephox-snooker-resizer-bar') === false;
+ return has$1(Element.fromDom(e.target), 'ephox-snooker-resizer-bar') === false;
};
function CellSelection$1 (editor, lazyResize) {
var handlerStruct = MixedBag([
@@ -8661,8 +8802,8 @@
var isRoot = getIsRoot(editor);
var syncSelection = function () {
var sel = editor.selection;
- var start = Element$$1.fromDom(sel.getStart());
- var end = Element$$1.fromDom(sel.getEnd());
+ var start = Element.fromDom(sel.getStart());
+ var end = Element.fromDom(sel.getEnd());
var shared = DomParent.sharedOne(TableLookup.table, [
start,
end
@@ -8684,8 +8825,8 @@
event.kill();
}
response.selection().each(function (ns) {
- var relative = relative$1(ns.start(), ns.finish());
- var rng = asLtrRange(win, relative);
+ var relative$1 = relative(ns.start(), ns.finish());
+ var rng = asLtrRange(win, relative$1);
editor.selection.setRng(rng);
});
};
@@ -8693,8 +8834,8 @@
var wrappedEvent = wrapEvent(event);
if (wrappedEvent.raw().shiftKey && SelectionKeys.isNavigation(wrappedEvent.raw().which)) {
var rng = editor.selection.getRng();
- var start = Element$$1.fromDom(rng.startContainer);
- var end = Element$$1.fromDom(rng.endContainer);
+ var start = Element.fromDom(rng.startContainer);
+ var end = Element.fromDom(rng.endContainer);
keyHandlers.keyup(wrappedEvent, start, rng.startOffset, end, rng.endOffset).each(function (response) {
handleResponse(wrappedEvent, response);
});
@@ -8706,9 +8847,9 @@
resize.hideBars();
});
var rng = editor.selection.getRng();
- var startContainer = Element$$1.fromDom(editor.selection.getStart());
- var start = Element$$1.fromDom(rng.startContainer);
- var end = Element$$1.fromDom(rng.endContainer);
+ var startContainer = Element.fromDom(editor.selection.getStart());
+ var start = Element.fromDom(rng.startContainer);
+ var end = Element.fromDom(rng.endContainer);
var direction = Direction.directionAt(startContainer).isRtl() ? SelectionKeys.rtl : SelectionKeys.ltr;
keyHandlers.keydown(wrappedEvent, start, rng.startOffset, end, rng.endOffset, direction).each(function (response) {
handleResponse(wrappedEvent, response);
@@ -8721,7 +8862,7 @@
return event.hasOwnProperty('x') && event.hasOwnProperty('y');
};
var wrapEvent = function (event) {
- var target = Element$$1.fromDom(event.target);
+ var target = Element.fromDom(event.target);
var stop = function () {
event.stopPropagation();
};
@@ -8973,7 +9114,7 @@
editor.on('nodechange', function (e) {
var cellOpt = Option.from(editor.dom.getParent(editor.selection.getStart(), 'th,td'));
targets = cellOpt.bind(function (cellDom) {
- var cell = Element$$1.fromDom(cellDom);
+ var cell = Element.fromDom(cellDom);
var table = TableLookup.table(cell);
return table.map(function (table) {
return TableTargets.forMenu(selections, table, cell);
@@ -9203,7 +9344,7 @@
});
};
var setClipboardRows = function (rows, clipboardRows) {
- var sugarRows = map(rows, Element$$1.fromDom);
+ var sugarRows = map(rows, Element.fromDom);
clipboardRows.set(Option.from(sugarRows));
};
var getApi = function (editor, clipboardRows) {
@@ -9252,5 +9393,5 @@
return Plugin$1;
-}());
+}(window));
})();

plugins/table/plugin.min.js

@@ -1 +1 @@
-!function(){"use strict";var e,t,n,r,o,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),y=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},x=function(n,r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(r.apply(null,arguments))}},C=function(e){return function(){return e}},u=function(e){return e},R=function(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var u=new Array(arguments.length-1),n=1;n<arguments.length;n++)u[n-1]=arguments[n];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];var o=u.concat(n);return i.apply(null,o)}},m=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return!n.apply(null,arguments)}},c=function(e){return e()},a=C(!1),l=C(!0),f=a,s=l,d=function(){return g},g=(r={fold:function(e,t){return e()},is:f,isSome:f,isNone:s,getOr:n=function(e){return e},getOrThunk:t=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:n,orThunk:t,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:f,forall:s,filter:d,equals:e=function(e){return e.isNone()},equals_:e,toArray:function(){return[]},toString:C("none()")},Object.freeze&&Object.freeze(r),r),h=function(n){var e=function(){return n},t=function(){return o},r=function(e){return e(n)},o={fold:function(e,t){return t(n)},is:function(e){return n===e},isSome:s,isNone:f,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return h(e(n))},ap:function(e){return e.fold(d,function(e){return h(e(n))})},each:function(e){e(n)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(n)?o:g},equals:function(e){return e.is(n)},equals_:function(e,t){return e.fold(f,function(e){return t(n,e)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},S={some:h,none:d,from:function(e){return null===e||e===undefined?g:h(e)}},p=function(t){return function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&Array.prototype.isPrototypeOf(e)?"array":"object"===t&&String.prototype.isPrototypeOf(e)?"string":t}(e)===t}},v=p("string"),b=p("array"),w=p("boolean"),T=p("function"),D=p("number"),O=(o=Array.prototype.indexOf)===undefined?function(e,t){return _(e,t)}:function(e,t){return o.call(e,t)},k=function(e,t){return-1<O(e,t)},N=function(e,t){return M(e,t).isSome()},E=function(e,t){for(var n=e.length,r=new Array(n),o=0;o<n;o++){var i=e[o];r[o]=t(i,o,e)}return r},A=function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n,e)},P=function(e,t){for(var n=[],r=0,o=e.length;r<o;r++){var i=e[r];t(i,r,e)&&n.push(i)}return n},I=function(e,t,n){return function(e,t){for(var n=e.length-1;0<=n;n--)t(e[n],n,e)}(e,function(e){n=t(n,e)}),n},B=function(e,t,n){return A(e,function(e){n=t(n,e)}),n},W=function(e,t){for(var n=0,r=e.length;n<r;n++){var o=e[n];if(t(o,n,e))return S.some(o)}return S.none()},M=function(e,t){for(var n=0,r=e.length;n<r;n++)if(t(e[n],n,e))return S.some(n);return S.none()},_=function(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return n;return-1},L=Array.prototype.push,F=function(e){for(var t=[],n=0,r=e.length;n<r;++n){if(!Array.prototype.isPrototypeOf(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);L.apply(t,e[n])}return t},j=function(e,t){var n=E(e,t);return F(n)},z=function(e,t){for(var n=0,r=e.length;n<r;++n)if(!0!==t(e[n],n,e))return!1;return!0},H=Array.prototype.slice,U=function(e){var t=H.call(e,0);return t.reverse(),t},q=(T(Array.from)&&Array.from,Object.keys),V=function(e,t){for(var n=q(e),r=0,o=n.length;r<o;r++){var i=n[r];t(e[i],i,e)}},G=function(e,r){return Y(e,function(e,t,n){return{k:t,v:r(e,t,n)}})},Y=function(r,o){var i={};return V(r,function(e,t){var n=o(e,t,r);i[n.k]=n.v}),i},X=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(t.length!==n.length)throw new Error('Wrong number of arguments to struct. Expected "['+t.length+']", got '+n.length+" arguments");var r={};return A(t,function(e,t){r[e]=C(n[t])}),r}},K=function(e){return e.slice(0).sort()},J=function(e,t){throw new Error("All required keys ("+K(e).join(", ")+") were not specified. Specified keys were: "+K(t).join(", ")+".")},$=function(e){throw new Error("Unsupported keys for object: "+K(e).join(", "))},Q=function(t,e){if(!b(e))throw new Error("The "+t+" fields must be an array. Was: "+e+".");A(e,function(e){if(!v(e))throw new Error("The value "+e+" in the "+t+" fields was not a string.")})},Z=function(e){var n=K(e);W(n,function(e,t){return t<n.length-1&&e===n[t+1]}).each(function(e){throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+n.join(", ")+"].")})},ee=function(o,i){var u=o.concat(i);if(0===u.length)throw new Error("You must specify at least one required or optional field.");return Q("required",o),Q("optional",i),Z(u),function(t){var n=q(t);z(o,function(e){return k(n,e)})||J(o,n);var e=P(n,function(e){return!k(u,e)});0<e.length&&$(e);var r={};return A(o,function(e){r[e]=C(t[e])}),A(i,function(e){r[e]=C(Object.prototype.hasOwnProperty.call(t,e)?S.some(t[e]):S.none())}),r}},te=X("width","height"),ne=X("rows","columns"),re=X("row","column"),oe=X("x","y"),ie=X("element","rowspan","colspan"),ue=X("element","rowspan","colspan","isNew"),ae={dimensions:te,grid:ne,address:re,coords:oe,extended:X("element","rowspan","colspan","row","column"),detail:ie,detailnew:ue,rowdata:X("element","cells","section"),elementnew:X("element","isNew"),rowdatanew:X("element","cells","section","isNew"),rowcells:X("cells","section"),rowdetails:X("details","section"),bounds:X("startRow","startCol","finishRow","finishCol")},ce=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:C(e)}},le={fromHtml:function(e,t){var n=(t||document).createElement("div");if(n.innerHTML=e,!n.hasChildNodes()||1<n.childNodes.length)throw console.error("HTML does not have a single root node",e),"HTML must have a single root node";return ce(n.childNodes[0])},fromTag:function(e,t){var n=(t||document).createElement(e);return ce(n)},fromText:function(e,t){var n=(t||document).createTextNode(e);return ce(n)},fromDom:ce,fromPoint:function(e,t,n){var r=e.dom();return S.from(r.elementFromPoint(t,n)).map(ce)}},fe=(Node.ATTRIBUTE_NODE,Node.CDATA_SECTION_NODE,Node.COMMENT_NODE),se=Node.DOCUMENT_NODE,de=(Node.DOCUMENT_TYPE_NODE,Node.DOCUMENT_FRAGMENT_NODE,Node.ELEMENT_NODE),me=Node.TEXT_NODE,ge=(Node.PROCESSING_INSTRUCTION_NODE,Node.ENTITY_REFERENCE_NODE,Node.ENTITY_NODE,Node.NOTATION_NODE,de),he=se,pe=function(e,t){var n=e.dom();if(n.nodeType!==ge)return!1;if(n.matches!==undefined)return n.matches(t);if(n.msMatchesSelector!==undefined)return n.msMatchesSelector(t);if(n.webkitMatchesSelector!==undefined)return n.webkitMatchesSelector(t);if(n.mozMatchesSelector!==undefined)return n.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")},ve=function(e){return e.nodeType!==ge&&e.nodeType!==he||0===e.childElementCount},be="undefined"!=typeof window?window:Function("return this;")(),we=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:be,r=0;r<e.length&&n!==undefined&&null!==n;++r)n=n[e[r]];return n}(e.split("."),t)},ye=function(e,t){var n=we(e,t);if(n===undefined||null===n)throw e+" not available on this browser";return n},xe=function(){return ye("Node")},Ce=function(e,t,n){return 0!=(e.compareDocumentPosition(t)&n)},Re=function(e,t){return Ce(e,t,xe().DOCUMENT_POSITION_CONTAINED_BY)},Se=function(n){var r,o=!1;return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o||(o=!0,r=n.apply(null,e)),r}},Te=function(e,t){var n=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.test(t))return r}return undefined}(e,t);if(!n)return{major:0,minor:0};var r=function(e){return Number(t.replace(n,"$"+e))};return Oe(r(1),r(2))},De=function(){return Oe(0,0)},Oe=function(e,t){return{major:e,minor:t}},ke={nu:Oe,detect:function(e,t){var n=String(t).toLowerCase();return 0===e.length?De():Te(e,n)},unknown:De},Ne="Firefox",Ee=function(e,t){return function(){return t===e}},Ae=function(e){var t=e.current;return{current:t,version:e.version,isEdge:Ee("Edge",t),isChrome:Ee("Chrome",t),isIE:Ee("IE",t),isOpera:Ee("Opera",t),isFirefox:Ee(Ne,t),isSafari:Ee("Safari",t)}},Pe={unknown:function(){return Ae({current:undefined,version:ke.unknown()})},nu:Ae,edge:C("Edge"),chrome:C("Chrome"),ie:C("IE"),opera:C("Opera"),firefox:C(Ne),safari:C("Safari")},Ie="Windows",Be="Android",We="Solaris",Me="FreeBSD",_e=function(e,t){return function(){return t===e}},Le=function(e){var t=e.current;return{current:t,version:e.version,isWindows:_e(Ie,t),isiOS:_e("iOS",t),isAndroid:_e(Be,t),isOSX:_e("OSX",t),isLinux:_e("Linux",t),isSolaris:_e(We,t),isFreeBSD:_e(Me,t)}},Fe={unknown:function(){return Le({current:undefined,version:ke.unknown()})},nu:Le,windows:C(Ie),ios:C("iOS"),android:C(Be),linux:C("Linux"),osx:C("OSX"),solaris:C(We),freebsd:C(Me)},je=function(e,t){var n=String(t).toLowerCase();return W(e,function(e){return e.search(n)})},ze=function(e,n){return je(e,n).map(function(e){var t=ke.detect(e.versionRegexes,n);return{current:e.name,version:t}})},He=function(e,n){return je(e,n).map(function(e){var t=ke.detect(e.versionRegexes,n);return{current:e.name,version:t}})},Ue=function(e,t){return-1!==e.indexOf(t)},qe=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Ve=function(t){return function(e){return Ue(e,t)}},Ge=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return Ue(e,"edge/")&&Ue(e,"chrome")&&Ue(e,"safari")&&Ue(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,qe],search:function(e){return Ue(e,"chrome")&&!Ue(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return Ue(e,"msie")||Ue(e,"trident")}},{name:"Opera",versionRegexes:[qe,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Ve("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Ve("firefox")},{name:"Safari",versionRegexes:[qe,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(Ue(e,"safari")||Ue(e,"mobile/"))&&Ue(e,"applewebkit")}}],Ye=[{name:"Windows",search:Ve("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return Ue(e,"iphone")||Ue(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Ve("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:Ve("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Ve("linux"),versionRegexes:[]},{name:"Solaris",search:Ve("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Ve("freebsd"),versionRegexes:[]}],Xe={browsers:C(Ge),oses:C(Ye)},Ke=function(e){var t,n,r,o,i,u,a,c,l,f,s,d=Xe.browsers(),m=Xe.oses(),g=ze(d,e).fold(Pe.unknown,Pe.nu),h=He(m,e).fold(Fe.unknown,Fe.nu);return{browser:g,os:h,deviceType:(n=g,r=e,o=(t=h).isiOS()&&!0===/ipad/i.test(r),i=t.isiOS()&&!o,u=t.isAndroid()&&3===t.version.major,a=t.isAndroid()&&4===t.version.major,c=o||u||a&&!0===/mobile/i.test(r),l=t.isiOS()||t.isAndroid(),f=l&&!c,s=n.isSafari()&&t.isiOS()&&!1===/safari/i.test(r),{isiPad:C(o),isiPhone:C(i),isTablet:C(c),isPhone:C(f),isTouch:C(l),isAndroid:t.isAndroid,isiOS:t.isiOS,isWebView:C(s)})}},Je={detect:Se(function(){var e=navigator.userAgent;return Ke(e)})},$e=function(e,t){return e.dom()===t.dom()},Qe=Je.detect().browser.isIE()?function(e,t){return Re(e.dom(),t.dom())}:function(e,t){var n=e.dom(),r=t.dom();return n!==r&&n.contains(r)},Ze=pe,et=function(e){return le.fromDom(e.dom().ownerDocument)},tt=function(e){var t=e.dom();return S.from(t.parentNode).map(le.fromDom)},nt=function(e,t){for(var n=T(t)?t:C(!1),r=e.dom(),o=[];null!==r.parentNode&&r.parentNode!==undefined;){var i=r.parentNode,u=le.fromDom(i);if(o.push(u),!0===n(u))break;r=i}return o},rt=function(e){var t=e.dom();return S.from(t.previousSibling).map(le.fromDom)},ot=function(e){var t=e.dom();return S.from(t.nextSibling).map(le.fromDom)},it=function(e){var t=e.dom();return E(t.childNodes,le.fromDom)},ut=function(e,t){var n=e.dom().childNodes;return S.from(n[t]).map(le.fromDom)},at=(X("element","offset"),function(e,t,n){return j(it(e),function(e){return pe(e,t)?n(e)?[e]:[]:at(e,t,n)})}),ct={firstLayer:function(e,t){return at(e,t,C(!0))},filterFirstLayer:at},lt=function(e){return e.dom().nodeName.toLowerCase()},ft=function(e){return e.dom().nodeType},st=function(t){return function(e){return ft(e)===t}},dt=function(e){return ft(e)===fe||"#comment"===lt(e)},mt=st(de),gt=st(me),ht=st(se),pt=function(e,t,n){if(!(v(n)||w(n)||D(n)))throw console.error("Invalid call to Attr.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")},vt=function(e,t,n){pt(e.dom(),t,n)},bt=function(e,t){var n=e.dom();V(t,function(e,t){pt(n,t,e)})},wt=function(e,t){var n=e.dom().getAttribute(t);return null===n?undefined:n},yt=function(e,t){var n=e.dom();return!(!n||!n.hasAttribute)&&n.hasAttribute(t)},xt=function(e,t){e.dom().removeAttribute(t)},Ct=function(e){return B(e.dom().attributes,function(e,t){return e[t.name]=t.value,e},{})},Rt=function(e){var t=gt(e)?e.dom().parentNode:e.dom();return t!==undefined&&null!==t&&t.ownerDocument.body.contains(t)},St=Se(function(){return Tt(le.fromDom(document))}),Tt=function(e){var t=e.dom().body;if(null===t||t===undefined)throw"Body is not available yet";return le.fromDom(t)},Dt=function(e,t){var n=[];return A(it(e),function(e){t(e)&&(n=n.concat([e])),n=n.concat(Dt(e,t))}),n},Ot=function(e,t,n){return r=function(e){return pe(e,t)},P(nt(e,n),r);var r},kt=function(e,t){return n=function(e){return pe(e,t)},P(it(e),n);var n},Nt=function(e,t){return n=t,o=(r=e)===undefined?document:r.dom(),ve(o)?[]:E(o.querySelectorAll(n),le.fromDom);var n,r,o};function Et(e,t,n,r,o){return e(n,r)?S.some(n):T(o)&&o(n)?S.none():t(n,r,o)}var At,Pt,It,Bt,Wt,Mt=function(e,t,n){for(var r=e.dom(),o=T(n)?n:C(!1);r.parentNode;){r=r.parentNode;var i=le.fromDom(r);if(t(i))return S.some(i);if(o(i))break}return S.none()},_t=function(e,t,n){return Mt(e,function(e){return pe(e,t)},n)},Lt=function(e,t){return n=function(e){return pe(e,t)},W(e.dom().childNodes,x(n,le.fromDom)).map(le.fromDom);var n},Ft=function(e,t){return n=t,o=(r=e)===undefined?document:r.dom(),ve(o)?S.none():S.from(o.querySelector(n)).map(le.fromDom);var n,r,o},jt=function(e,t,n){return Et(pe,_t,e,t,n)},zt=function(e,t,n){var r=n!==undefined?n:C(!1);return r(t)?S.none():k(e,lt(t))?S.some(t):_t(t,e.join(","),function(e){return pe(e,"table")||r(e)})},Ht=function(t,e){return tt(e).map(function(e){return kt(e,t)})},Ut=R(Ht,"th,td"),qt=R(Ht,"tr"),Vt=function(e,t){return parseInt(wt(e,t),10)},Gt={cell:function(e,t){return zt(["td","th"],e,t)},firstCell:function(e){return Ft(e,"th,td")},cells:function(e){return ct.firstLayer(e,"th,td")},neighbourCells:Ut,table:function(e,t){return jt(e,"table",t)},row:function(e,t){return zt(["tr"],e,t)},rows:function(e){return ct.firstLayer(e,"tr")},notCell:function(e,t){return zt(["caption","tr","tbody","tfoot","thead"],e,t)},neighbourRows:qt,attr:Vt,grid:function(e,t,n){var r=Vt(e,t),o=Vt(e,n);return ae.grid(r,o)}},Yt=function(e){var t=Gt.rows(e);return E(t,function(e){var t=e,n=tt(t).map(function(e){var t=lt(e);return"tfoot"===t||"thead"===t||"tbody"===t?t:"tbody"}).getOr("tbody"),r=E(Gt.cells(e),function(e){var t=yt(e,"rowspan")?parseInt(wt(e,"rowspan"),10):1,n=yt(e,"colspan")?parseInt(wt(e,"colspan"),10):1;return ae.detail(e,t,n)});return ae.rowdata(t,r,n)})},Xt=function(e,n){return E(e,function(e){var t=E(Gt.cells(e),function(e){var t=yt(e,"rowspan")?parseInt(wt(e,"rowspan"),10):1,n=yt(e,"colspan")?parseInt(wt(e,"colspan"),10):1;return ae.detail(e,t,n)});return ae.rowdata(e,t,n.section())})},Kt=function(e,t){return e+","+t},Jt=function(e,t){var n=j(e.all(),function(e){return e.cells()});return P(n,t)},$t={generate:function(e){var f={},t=[],n=e.length,s=0;A(e,function(e,c){var l=[];A(e.cells(),function(e,t){for(var n=0;f[Kt(c,n)]!==undefined;)n++;for(var r=ae.extended(e.element(),e.rowspan(),e.colspan(),c,n),o=0;o<e.colspan();o++)for(var i=0;i<e.rowspan();i++){var u=n+o,a=Kt(c+i,u);f[a]=r,s=Math.max(s,u+1)}l.push(r)}),t.push(ae.rowdata(e.element(),l,e.section()))});var r=ae.grid(n,s);return{grid:C(r),access:C(f),all:C(t)}},getAt:function(e,t,n){var r=e.access()[Kt(t,n)];return r!==undefined?S.some(r):S.none()},findItem:function(e,t,n){var r=Jt(e,function(e){return n(t,e.element())});return 0<r.length?S.some(r[0]):S.none()},filterItems:Jt,justCells:function(e){var t=E(e.all(),function(e){return e.cells()});return F(t)}},Qt=function(e){return e.style!==undefined},Zt=function(e,t,n){if(!v(n))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,":: Element ",e),new Error("CSS value must be a string: "+n);Qt(e)&&e.style.setProperty(t,n)},en=function(e,t,n){var r=e.dom();Zt(r,t,n)},tn=function(e,t){var n=e.dom();V(t,function(e,t){Zt(n,t,e)})},nn=function(e,t){var n=e.dom(),r=window.getComputedStyle(n).getPropertyValue(t),o=""!==r||Rt(e)?r:rn(n,t);return null===o?undefined:o},rn=function(e,t){return Qt(e)?e.style.getPropertyValue(t):""},on=function(e,t){var n=e.dom(),r=rn(n,t);return S.from(r).filter(function(e){return 0<e.length})},un=function(e,t){var n,r,o=e.dom();r=t,Qt(n=o)&&n.style.removeProperty(r),yt(e,"style")&&""===wt(e,"style").replace(/^\s+|\s+$/g,"")&&xt(e,"style")},an=function(t,n){tt(t).each(function(e){e.dom().insertBefore(n.dom(),t.dom())})},cn=function(e,t){ot(e).fold(function(){tt(e).each(function(e){fn(e,t)})},function(e){an(e,t)})},ln=function(t,n){ut(t,0).fold(function(){fn(t,n)},function(e){t.dom().insertBefore(n.dom(),e.dom())})},fn=function(e,t){e.dom().appendChild(t.dom())},sn=function(e,t){an(e,t),fn(t,e)},dn=function(r,o){A(o,function(e,t){var n=0===t?r:o[t-1];cn(n,e)})},mn=function(t,e){A(e,function(e){fn(t,e)})},gn=function(e){e.dom().textContent="",A(it(e),function(e){hn(e)})},hn=function(e){var t=e.dom();null!==t.parentNode&&t.parentNode.removeChild(t)},pn=function(e){var t,n=it(e);0<n.length&&(t=e,A(n,function(e){an(t,e)})),hn(e)},vn=X("minRow","minCol","maxRow","maxCol"),bn=function(e,t){var n,i,r,u,a,c,l,o,f,s,d=function(e){return pe(e.element(),t)},m=Yt(e),g=$t.generate(m),h=(i=d,r=(n=g).grid().columns(),u=n.grid().rows(),a=r,l=c=0,V(n.access(),function(e){if(i(e)){var t=e.row(),n=t+e.rowspan()-1,r=e.column(),o=r+e.colspan()-1;t<u?u=t:c<n&&(c=n),r<a?a=r:l<o&&(l=o)}}),vn(u,a,c,l)),p="th:not("+t+"),td:not("+t+")",v=ct.filterFirstLayer(e,"th,td",function(e){return pe(e,p)});return A(v,hn),function(e,t,n,r){for(var o,i,u,a=t.grid().columns(),c=t.grid().rows(),l=0;l<c;l++)for(var f=!1,s=0;s<a;s++)l<n.minRow()||l>n.maxRow()||s<n.minCol()||s>n.maxCol()||($t.getAt(t,l,s).filter(r).isNone()?(o=f,i=e[l].element(),u=le.fromTag("td"),fn(u,le.fromTag("br")),(o?fn:ln)(i,u)):f=!0)}(m,g,h,d),o=e,f=h,s=P(ct.firstLayer(o,"tr"),function(e){return 0===e.dom().childElementCount}),A(s,hn),f.minCol()!==f.maxCol()&&f.minRow()!==f.maxRow()||A(ct.firstLayer(o,"th,td"),function(e){xt(e,"rowspan"),xt(e,"colspan")}),xt(o,"width"),xt(o,"height"),un(o,"width"),un(o,"height"),e},wn=function(e,t){return le.fromDom(e.dom().cloneNode(t))},yn=function(e){return wn(e,!1)},xn=function(e){return wn(e,!0)},Cn=function(e,t){var n,r,o,i,u=(n=e,r=t,o=le.fromTag(r),i=Ct(n),bt(o,i),o),a=it(xn(e));return mn(u,a),u},Rn=(At=gt,Pt="text",It=function(e){return At(e)?S.from(e.dom().nodeValue):S.none()},Bt=Je.detect().browser,{get:function(e){if(!At(e))throw new Error("Can only get "+Pt+" value of a "+Pt+" node");return Wt(e).getOr("")},getOption:Wt=Bt.isIE()&&10===Bt.version.major?function(e){try{return It(e)}catch(t){return S.none()}}:It,set:function(e,t){if(!At(e))throw new Error("Can only set raw "+Pt+" value of a "+Pt+" node");e.dom().nodeValue=t}}),Sn=function(e){return Rn.get(e)},Tn=function(e){return Rn.getOption(e)},Dn=function(e,t){Rn.set(e,t)},On=function(e){return"img"===lt(e)?1:Tn(e).fold(function(){return it(e).length},function(e){return e.length})},kn=["img","br"],Nn=function(e){return Tn(e).filter(function(e){return 0!==e.trim().length||-1<e.indexOf("\xa0")}).isSome()||k(kn,lt(e))},En=function(e){return r=Nn,(o=function(e){for(var t=0;t<e.childNodes.length;t++){if(r(le.fromDom(e.childNodes[t])))return S.some(le.fromDom(e.childNodes[t]));var n=o(e.childNodes[t]);if(n.isSome())return n}return S.none()})(e.dom());var r,o},An=function(e){return Pn(e,Nn)},Pn=function(e,i){var u=function(e){for(var t=it(e),n=t.length-1;0<=n;n--){var r=t[n];if(i(r))return S.some(r);var o=u(r);if(o.isSome())return o}return S.none()};return u(e)},In=function(){var e=le.fromTag("td");return fn(e,le.fromTag("br")),e},Bn=function(e,t,n){var r=Cn(e,t);return V(n,function(e,t){null===e?xt(r,t):vt(r,t,e)}),r},Wn=function(e){return e},Mn=function(e){return function(){return le.fromTag("tr",e.dom())}},_n=function(d,e,m){return{row:Mn(e),cell:function(e){var r,o,i,t,n,u,a,c=et(e.element()),l=le.fromTag(lt(e.element()),c.dom()),f=m.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),s=0<f.length?(r=e.element(),o=l,i=f,En(r).map(function(e){var t=i.join(","),n=Ot(e,t,function(e){return $e(e,r)});return I(n,function(e,t){var n=yn(t);return xt(n,"contenteditable"),fn(e,n),n},o)}).getOr(o)):l;return fn(s,le.fromTag("br")),t=e.element(),n=l,u=t.dom(),a=n.dom(),Qt(u)&&Qt(a)&&(a.style.cssText=u.style.cssText),un(l,"height"),1!==e.colspan()&&un(e.element(),"width"),d(e.element(),l),l},replace:Bn,gap:In}},Ln=function(e){return{row:Mn(e),cell:In,replace:Wn,gap:In}},Fn=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"];function jn(){return{up:C({selector:_t,closest:jt,predicate:Mt,all:nt}),down:C({selector:Nt,predicate:Dt}),styles:C({get:nn,getRaw:on,set:en,remove:un}),attrs:C({get:wt,set:vt,remove:xt,copyTo:function(e,t){var n=Ct(e);bt(t,n)}}),insert:C({before:an,after:cn,afterAll:dn,append:fn,appendAll:mn,prepend:ln,wrap:sn}),remove:C({unwrap:pn,remove:hn}),create:C({nu:le.fromTag,clone:function(e){return le.fromDom(e.dom().cloneNode(!1))},text:le.fromText}),query:C({comparePosition:function(e,t){return e.dom().compareDocumentPosition(t.dom())},prevSibling:rt,nextSibling:ot}),property:C({children:it,name:lt,parent:tt,isText:gt,isComment:dt,isElement:mt,getText:Sn,setText:Dn,isBoundary:function(e){return!!mt(e)&&("body"===lt(e)||k(Fn,lt(e)))},isEmptyTag:function(e){return!!mt(e)&&k(["br","img","hr","input"],lt(e))}}),eq:$e,is:Ze}}var zn=X("left","right"),Hn=function(e,t,n){var r=e.property().children(t);return M(r,R(e.eq,n)).map(function(e){return{before:C(r.slice(0,e)),after:C(r.slice(e+1))}})},Un=function(n,r,o){return Hn(n,r,o).map(function(e){var t=n.create().clone(r);return n.insert().appendAll(t,e.before().concat([o])),n.insert().appendAll(r,e.after()),n.insert().before(r,t),zn(t,r)})},qn=function(n,r,e){return Hn(n,r,e).map(function(e){var t=n.create().clone(r);return n.insert().appendAll(t,e.after()),n.insert().after(r,t),zn(r,t)})},Vn=function(i,e,u,a){var r=X("first","second","splits"),c=function(e,t,o){var n=r(e,S.none(),o);return u(e)?r(e,t,o):i.property().parent(e).bind(function(r){return a(i,r,e).map(function(e){var t=[{first:e.left,second:e.right}],n=u(r)?r:e.left();return c(n,S.some(e.right()),o.concat(t))}).getOr(n)})};return c(e,S.none(),[])},Gn=function(r,o,e,t){var n=o(r,e);return I(t,function(e,t){var n=o(r,t);return Yn(r,e,n)},n)},Yn=function(t,e,n){return e.bind(function(e){return n.filter(R(t.eq,e))})},Xn=function(e,t,n){return 0<n.length?Gn(e,t,(r=n)[0],r.slice(1)):S.none();var r},Kn=function(e,t){return R(e.eq,t)},Jn=function(t,e,n,r){var o=r!==undefined?r:C(!1),i=[e].concat(t.up().all(e)),u=[n].concat(t.up().all(n)),a=function(t){return M(t,o).fold(function(){return t},function(e){return t.slice(0,e+1)})},c=a(i),l=a(u),f=W(c,function(e){return N(l,Kn(t,e))});return{firstpath:C(c),secondpath:C(l),shared:C(f)}},$n=function(t,e,n){var r=Jn(t,e,n);return r.shared().bind(function(e){return function(o,i,e,t){var u=o.property().children(i);if(o.eq(i,e[0]))return S.some([e[0]]);if(o.eq(i,t[0]))return S.some([t[0]]);var n=function(e){var t=U(e),n=M(t,Kn(o,i)).getOr(-1),r=n<t.length-1?t[n+1]:t[n];return M(u,Kn(o,r))},r=n(e),a=n(t);return r.bind(function(r){return a.map(function(e){var t=Math.min(r,e),n=Math.max(r,e);return u.slice(t,n+1)})})}(t,e,r.firstpath(),r.secondpath())})},Qn=Jn,Zn=function(e,t,n){return Xn(e,t,n)},er=function(e,t,n){return $n(e,t,n)},tr=function(e,t,n,r){return Qn(e,t,n,r)},nr=function(e,t,n){return Un(e,t,n)},rr=function(e,t,n){return qn(e,t,n)},or=function(e,t,n,r){return Vn(e,t,n,r)},ir=jn(),ur={sharedOne:function(n,e){return Zn(ir,function(e,t){return n(t)},e)},subset:function(e,t){return er(ir,e,t)},ancestors:function(e,t,n){return tr(ir,e,t,n)},breakToLeft:function(e,t){return nr(ir,e,t)},breakToRight:function(e,t){return rr(ir,e,t)},breakPath:function(e,t,r){return or(ir,e,t,function(e,t,n){return r(t,n)})}},ar=function(e,t){return t.column()>=e.startCol()&&t.column()+t.colspan()-1<=e.finishCol()&&t.row()>=e.startRow()&&t.row()+t.rowspan()-1<=e.finishRow()},cr=function(e,t){var n=t.column(),r=t.column()+t.colspan()-1,o=t.row(),i=t.row()+t.rowspan()-1;return n<=e.finishCol()&&r>=e.startCol()&&o<=e.finishRow()&&i>=e.startRow()},lr=function(e,t){for(var n=!0,r=R(ar,t),o=t.startRow();o<=t.finishRow();o++)for(var i=t.startCol();i<=t.finishCol();i++)n=n&&$t.getAt(e,o,i).exists(r);return n?S.some(t):S.none()},fr=function(e,t,n){var r=$t.findItem(e,t,$e),o=$t.findItem(e,n,$e);return r.bind(function(r){return o.map(function(e){return t=r,n=e,ae.bounds(Math.min(t.row(),n.row()),Math.min(t.column(),n.column()),Math.max(t.row()+t.rowspan()-1,n.row()+n.rowspan()-1),Math.max(t.column()+t.colspan()-1,n.column()+n.colspan()-1));var t,n})})},sr=fr,dr=function(t,e,n){return fr(t,e,n).bind(function(e){return lr(t,e)})},mr=function(r,e,o,i){return $t.findItem(r,e,$e).bind(function(e){var t=0<o?e.row()+e.rowspan()-1:e.row(),n=0<i?e.column()+e.colspan()-1:e.column();return $t.getAt(r,t+o,n+i).map(function(e){return e.element()})})},gr=function(n,e,t){return sr(n,e,t).map(function(e){var t=$t.filterItems(n,R(cr,e));return E(t,function(e){return e.element()})})},hr=function(e,t){return $t.findItem(e,t,function(e,t){return Qe(t,e)}).bind(function(e){return e.element()})},pr=function(e){var t=Yt(e);return $t.generate(t)},vr=function(n,r,o){return Gt.table(n).bind(function(e){var t=pr(e);return mr(t,n,r,o)})},br=function(e,t,n){var r=pr(e);return gr(r,t,n)},wr=function(e,t,n,r,o){var i=pr(e),u=$e(e,n)?t:hr(i,t),a=$e(e,o)?r:hr(i,r);return gr(i,u,a)},yr=function(e,t,n){var r=pr(e);return dr(r,t,n)},xr=function(e,t){return _t(e,"table")},Cr=ee(["boxes","start","finish"],[]),Rr=function(a,c,r){var l=function(t){return function(e){return r(e)||$e(e,t)}};return $e(a,c)?S.some(Cr({boxes:S.some([a]),start:a,finish:c})):xr(a).bind(function(u){return xr(c).bind(function(i){if($e(u,i))return S.some(Cr({boxes:br(u,a,c),start:a,finish:c}));if(Qe(u,i)){var e=0<(t=Ot(c,"td,th",l(u))).length?t[t.length-1]:c;return S.some(Cr({boxes:wr(u,a,u,c,i),start:a,finish:e}))}if(Qe(i,u)){var t,n=0<(t=Ot(a,"td,th",l(i))).length?t[t.length-1]:a;return S.some(Cr({boxes:wr(i,a,u,c,i),start:a,finish:n}))}return ur.ancestors(a,c).shared().bind(function(e){return jt(e,"table",r).bind(function(e){var t=Ot(c,"td,th",l(e)),n=0<t.length?t[t.length-1]:c,r=Ot(a,"td,th",l(e)),o=0<r.length?r[r.length-1]:a;return S.some(Cr({boxes:wr(e,a,u,c,i),start:o,finish:n}))})})})})},Sr=Rr,Tr=function(e,t){var n=Nt(e,t);return 0<n.length?S.some(n):S.none()},Dr=function(e,t,n,r,o){return(i=e,u=o,W(i,function(e){return pe(e,u)})).bind(function(e){return vr(e,t,n).bind(function(e){return n=r,_t(t=e,"table").bind(function(e){return Ft(e,n).bind(function(e){return Rr(e,t).bind(function(t){return t.boxes().map(function(e){return{boxes:C(e),start:C(t.start()),finish:C(t.finish())}})})})});var t,n})});var i,u},Or=function(e,t,r){return Ft(e,t).bind(function(n){return Ft(e,r).bind(function(t){return ur.sharedOne(xr,[n,t]).map(function(e){return{first:C(n),last:C(t),table:C(e)}})})})},kr=function(e,t){return Tr(e,t)},Nr=function(o,e,t){return Or(o,e,t).bind(function(n){var e=function(e){return $e(o,e)},t=_t(n.first(),"thead,tfoot,tbody,table",e),r=_t(n.last(),"thead,tfoot,tbody,table",e);return t.bind(function(t){return r.bind(function(e){return $e(t,e)?yr(n.table(),n.first(),n.last()):S.none()})})})},Er="data-mce-selected",Ar="data-mce-first-selected",Pr="data-mce-last-selected",Ir={selected:C(Er),selectedSelector:C("td[data-mce-selected],th[data-mce-selected]"),attributeSelector:C("[data-mce-selected]"),firstSelected:C(Ar),firstSelectedSelector:C("td[data-mce-first-selected],th[data-mce-first-selected]"),lastSelected:C(Pr),lastSelectedSelector:C("td[data-mce-last-selected],th[data-mce-last-selected]")},Br=function(u){if(!b(u))throw new Error("cases must be an array");if(0===u.length)throw new Error("there must be at least one case");var a=[],n={};return A(u,function(e,r){var t=q(e);if(1!==t.length)throw new Error("one and only one name per case");var o=t[0],i=e[o];if(n[o]!==undefined)throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!b(i))throw new Error("case arguments must be an array");a.push(o),n[o]=function(){var e=arguments.length;if(e!==i.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+i.length+" ("+i+"), got "+e);for(var n=new Array(e),t=0;t<n.length;t++)n[t]=arguments[t];return{fold:function(){if(arguments.length!==u.length)throw new Error("Wrong number of arguments to fold. Expected "+u.length+", got "+arguments.length);return arguments[r].apply(null,n)},match:function(e){var t=q(e);if(a.length!==t.length)throw new Error("Wrong number of arguments to match. Expected: "+a.join(",")+"\nActual: "+t.join(","));if(!z(a,function(e){return k(t,e)}))throw new Error("Not all branches were specified when using match. Specified: "+t.join(", ")+"\nRequired: "+a.join(", "));return e[o].apply(null,n)},log:function(e){console.log(e,{constructors:a,constructor:o,params:n})}}}}),n},Wr=Br([{none:[]},{multiple:["elements"]},{single:["selection"]}]),Mr={cata:function(e,t,n,r){return e.fold(t,n,r)},none:Wr.none,multiple:Wr.multiple,single:Wr.single},_r=function(e,t){return Mr.cata(t.get(),C([]),u,C([e]))},Lr=function(n,e){return Mr.cata(e.get(),S.none,function(t,e){return 0===t.length?S.none():Nr(n,Ir.firstSelectedSelector(),Ir.lastSelectedSelector()).bind(function(e){return 1<t.length?S.some({bounds:C(e),cells:C(t)}):S.none()})},S.none)},Fr=function(e,t){var n=_r(e,t);return 0<n.length&&z(n,function(e){return yt(e,"rowspan")&&1<parseInt(wt(e,"rowspan"),10)||yt(e,"colspan")&&1<parseInt(wt(e,"colspan"),10)})?S.some(n):S.none()},jr=_r,zr=function(e){return{element:C(e),mergable:S.none,unmergable:S.none,selection:C([e])}},Hr=X("element","clipboard","generators"),Ur={noMenu:zr,forMenu:function(e,t,n){return{element:C(n),mergable:C(Lr(t,e)),unmergable:C(Fr(n,e)),selection:C(jr(n,e))}},notCell:function(e){return zr(e)},paste:Hr,pasteRows:function(e,t,n,r,o){return{element:C(n),mergable:S.none,unmergable:S.none,selection:C(jr(n,e)),clipboard:C(r),generators:C(o)}}},qr=function(f,e,s,d){f.on("BeforeGetContent",function(n){!0===n.selection&&Mr.cata(e.get(),y,function(e){var t;n.preventDefault(),(t=e,Gt.table(t[0]).map(xn).map(function(e){return[bn(e,Ir.attributeSelector())]})).each(function(e){n.content=E(e,function(e){return t=e,f.selection.serializer.serialize(t.dom(),{});var t}).join("")})},y)}),f.on("BeforeSetContent",function(l){!0===l.selection&&!0===l.paste&&S.from(f.dom.getParent(f.selection.getStart(),"th,td")).each(function(e){var c=le.fromDom(e);Gt.table(c).bind(function(t){var e,n,r,o=P((e=l.content,(r=(n||document).createElement("div")).innerHTML=e,it(le.fromDom(r))),function(e){return"meta"!==lt(e)});if(1===o.length&&"table"===lt(o[0])){l.preventDefault();var i=le.fromDom(f.getDoc()),u=Ln(i),a=Ur.paste(c,o[0],u);s.pasteCells(t,a).each(function(e){f.selection.setRng(e),f.focus(),d.clear(t)})}})})})};function Vr(r,o){var e=function(e){var t=o(e);if(t<=0||null===t){var n=nn(e,r);return parseFloat(n)||0}return t},i=function(o,e){return B(e,function(e,t){var n=nn(o,t),r=n===undefined?0:parseInt(n,10);return isNaN(r)?e:e+r},0)};return{set:function(e,t){if(!D(t)&&!t.match(/^[0-9]+$/))throw r+".set accepts only positive integer values. Value was "+t;var n=e.dom();Qt(n)&&(n.style[r]=t+"px")},get:e,getOuter:e,aggregate:i,max:function(e,t,n){var r=i(e,n);return r<t?t-r:0}}}var Gr=Vr("height",function(e){var t=e.dom();return Rt(e)?t.getBoundingClientRect().height:t.offsetHeight}),Yr=function(e){return Gr.get(e)},Xr=function(e){return Gr.getOuter(e)},Kr=Vr("width",function(e){return e.dom().offsetWidth}),Jr=function(e){return Kr.get(e)},$r=function(e){return Kr.getOuter(e)},Qr=Je.detect(),Zr=function(e,t,n){return r=nn(e,t),o=n,i=parseFloat(r),isNaN(i)?o:i;var r,o,i},eo=function(e){return Qr.browser.isIE()||Qr.browser.isEdge()?(n=Zr(t=e,"padding-top",0),r=Zr(t,"padding-bottom",0),o=Zr(t,"border-top-width",0),i=Zr(t,"border-bottom-width",0),u=t.dom().getBoundingClientRect().height,"border-box"===nn(t,"box-sizing")?u:u-n-r-(o+i)):Zr(e,"height",Yr(e));var t,n,r,o,i,u},to=/(\d+(\.\d+)?)(\w|%)*/,no=/(\d+(\.\d+)?)%/,ro=/(\d+(\.\d+)?)px|em/,oo=function(e,t){en(e,"height",t+"px")},io=function(e,t,n,r){var o,i,u,a,c,l,f,s,d,m=parseInt(e,10);return s=l="%",d=(f=e).length-l.length,""!==s&&(f.length<s.length||f.substr(d,d+s.length)!==s)||"table"===lt(t)?m:(o=t,i=m,u=n,a=r,c=Gt.table(o).map(function(e){var t=u(e);return Math.floor(i/100*t)}).getOr(i),a(o,c),c)},uo=function(e){var t,n=on(t=e,"height").getOrThunk(function(){return eo(t)+"px"});return n?io(n,e,Yr,oo):Yr(e)},ao=function(e,t){return yt(e,t)?parseInt(wt(e,t),10):1},co=function(e){return on(e,"width").fold(function(){return S.from(wt(e,"width"))},function(e){return S.some(e)})},lo=function(e,t){return e/t.pixelWidth()*100},fo={percentageBasedSizeRegex:C(no),pixelBasedSizeRegex:C(ro),setPixelWidth:function(e,t){en(e,"width",t+"px")},setPercentageWidth:function(e,t){en(e,"width",t+"%")},setHeight:oo,getPixelWidth:function(t,n){return co(t).fold(function(){return Jr(t)},function(e){return function(e,t,n){if(ro.test(t)){var r=ro.exec(t);return parseInt(r[1],10)}if(no.test(t)){var o=no.exec(t),i=parseFloat(o[1]);return i/100*n.pixelWidth()}return Jr(e)}(t,e,n)})},getPercentageWidth:function(t,n){return co(t).fold(function(){var e=Jr(t);return lo(e,n)},function(e){return function(e,t,n){if(no.test(t)){var r=no.exec(t);return parseFloat(r[1])}var o=Jr(e);return lo(o,n)}(t,e,n)})},getGenericWidth:function(e){return co(e).bind(function(e){if(to.test(e)){var t=to.exec(e);return S.some({width:C(t[1]),unit:C(t[3])})}return S.none()})},setGenericWidth:function(e,t,n){en(e,"width",t+n)},getHeight:function(e){return n="rowspan",uo(t=e)/ao(t,n);var t,n},getRawWidth:co},so=function(n,r){fo.getGenericWidth(n).each(function(e){var t=e.width()/2;fo.setGenericWidth(n,t,e.unit()),fo.setGenericWidth(r,t,e.unit())})},mo=function(n,r){return{left:C(n),top:C(r),translate:function(e,t){return mo(n+e,r+t)}}},go=mo,ho=function(e,t){return e!==undefined?e:t!==undefined?t:0},po=function(e){var t,n,r=e.dom().ownerDocument,o=r.body,i=(t=le.fromDom(r),(n=t.dom())===n.window&&t instanceof Window?t:ht(t)?n.defaultView||n.parentWindow:null),u=r.documentElement,a=ho(i.pageYOffset,u.scrollTop),c=ho(i.pageXOffset,u.scrollLeft),l=ho(u.clientTop,o.clientTop),f=ho(u.clientLeft,o.clientLeft);return vo(e).translate(c-f,a-l)},vo=function(e){var t,n,r,o=e.dom(),i=o.ownerDocument,u=i.body,a=le.fromDom(i.documentElement);return u===o?go(u.offsetLeft,u.offsetTop):(t=e,n=a||le.fromDom(document.documentElement),Mt(t,R($e,n)).isSome()?(r=o.getBoundingClientRect(),go(r.left,r.top)):go(0,0))},bo=X("row","y"),wo=X("col","x"),yo=function(e){return po(e).left()+$r(e)},xo=function(e){return po(e).left()},Co=function(e,t){return wo(e,xo(t))},Ro=function(e,t){return wo(e,yo(t))},So=function(e){return po(e).top()},To=function(n,t,r){if(0===r.length)return[];var e=E(r.slice(1),function(e,t){return e.map(function(e){return n(t,e)})}),o=r[r.length-1].map(function(e){return t(r.length-1,e)});return e.concat([o])},Do={delta:u,positions:R(To,function(e,t){return bo(e,So(t))},function(e,t){return bo(e,So(t)+Xr(t))}),edge:So},Oo={delta:u,edge:xo,positions:R(To,Co,Ro)},ko={height:Do,rtl:{delta:function(e,t){return-e},edge:yo,positions:R(To,Ro,Co)},ltr:Oo},No={ltr:ko.ltr,rtl:ko.rtl};function Eo(t){var n=function(e){return t(e).isRtl()?No.rtl:No.ltr};return{delta:function(e,t){return n(t).delta(e,t)},edge:function(e){return n(e).edge(e)},positions:function(e,t){return n(t).positions(e,t)}}}var Ao,Po=function(e){var t=Yt(e);return $t.generate(t).grid()},Io=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return Io(n())}}},Bo=function(r,o,i){if(0===o.length)throw new Error("You must specify at least one required field.");return Q("required",o),Z(o),function(t){var n=q(t);z(o,function(e){return k(n,e)})||J(o,n),r(o,n);var e=P(o,function(e){return!i.validate(t[e],e)});return 0<e.length&&function(e,t){throw new Error("All values need to be of type: "+t+". Keys ("+K(e).join(", ")+") were not.")}(e,i.label),t}},Wo=function(t,e){var n=P(e,function(e){return!k(t,e)});0<n.length&&$(n)},Mo=function(e){return Bo(Wo,e,{validate:T,label:"function"})},_o=function(e){var t=yt(e,"colspan")?parseInt(wt(e,"colspan"),10):1,n=yt(e,"rowspan")?parseInt(wt(e,"rowspan"),10):1;return{element:C(e),colspan:C(t),rowspan:C(n)}},Lo=Mo(["cell","row","replace","gap"]),Fo=function(r,e){Lo(r);var n=Io(S.none()),o=e!==undefined?e:_o,i=function(e){var t,n=o(e);return t=n,r.cell(t)},u=function(e){var t=i(e);return n.get().isNone()&&n.set(S.some(t)),a=S.some({item:e,replacement:t}),t},a=S.none();return{getOrInit:function(t,n){return a.fold(function(){return u(t)},function(e){return n(t,e.item)?e.replacement:u(t)})},cursor:n.get}},jo=function(o,a){return function(n){var r=Io(S.none());Lo(n);var i=[],u=function(e){var t=n.replace(e,a,{scope:o});return i.push({item:e,sub:t}),r.get().isNone()&&r.set(S.some(t)),t};return{replaceOrInit:function(t,n){return(r=t,o=n,W(i,function(e){return o(e.item,r)})).fold(function(){return u(t)},function(e){return n(t,e.item)?e.sub:u(t)});var r,o},cursor:r.get}}},zo=function(n){Lo(n);var e=Io(S.none());return{combine:function(t){return e.get().isNone()&&e.set(S.some(t)),function(){var e=n.cell({element:C(t),colspan:C(1),rowspan:C(1)});return un(e,"width"),un(t,"width"),e}},cursor:e.get}},Ho=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],Uo=function(e,t){var n=e.property().name(t);return k(Ho,n)},qo=function(e,t){return k(["br","img","hr","input"],e.property().name(t))},Vo=Uo,Go=function(e,t){var n=e.property().name(t);return k(["ol","ul"],n)},Yo=qo,Xo=jn(),Ko=function(e){return Vo(Xo,e)},Jo=function(e){return Go(Xo,e)},$o=function(e){return Yo(Xo,e)},Qo=function(e){var t,i=function(e){return"br"===lt(e)},n=function(o){return An(o).bind(function(n){var r=ot(n).map(function(e){return!!Ko(e)||($o(e)?"img"!==lt(e):void 0)}).getOr(!1);return tt(n).map(function(e){return!0===r||"li"===lt(t=e)||Mt(t,Jo).isSome()||i(n)||Ko(e)&&!$e(o,e)?[]:[le.fromTag("br")];var t})}).getOr([])},r=0===(t=j(e,function(e){var t=it(e);return z(t,function(e){return i(e)||gt(e)&&0===Sn(e).trim().length})?[]:t.concat(n(e))})).length?[le.fromTag("br")]:t;gn(e[0]),mn(e[0],r)},Zo=Object.prototype.hasOwnProperty,ei=(Ao=function(e,t){return t},function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var o=e[r];for(var i in o)Zo.call(o,i)&&(n[i]=Ao(n[i],o[i]))}return n}),ti=function(e){for(var t=[],n=function(e){t.push(e)},r=0;r<e.length;r++)e[r].each(n);return t},ni=function(e,t){for(var n=0;n<e.length;n++){var r=t(e[n],n);if(r.isSome())return r}return S.none()},ri=function(e,t){return ae.rowcells(t,e.section())},oi=function(e,t){return e.cells()[t]},ii={addCell:function(e,t,n){var r=e.cells(),o=r.slice(0,t),i=r.slice(t),u=o.concat([n]).concat(i);return ri(e,u)},setCells:ri,mutateCell:function(e,t,n){e.cells()[t]=n},getCell:oi,getCellElement:function(e,t){return oi(e,t).element()},mapCells:function(e,t){var n=e.cells(),r=E(n,t);return ae.rowcells(r,e.section())},cellLength:function(e){return e.cells().length}},ui=function(e,t){if(0===e.length)return 0;var n=e[0];return M(e,function(e){return!t(n.element(),e.element())}).fold(function(){return e.length},function(e){return e})},ai=function(e,t,n,r){var o,i,u,a,c=(o=e,i=t,o[i]).cells().slice(n),l=ui(c,r),f=(u=e,a=n,E(u,function(e){return ii.getCell(e,a)})).slice(t),s=ui(f,r);return{colspan:C(l),rowspan:C(s)}},ci=function(o,i){var u=E(o,function(e,t){return E(e.cells(),function(e,t){return!1})});return E(o,function(e,r){var t=j(e.cells(),function(e,t){if(!1===u[r][t]){var n=ai(o,r,t,i);return function(e,t,n,r){for(var o=e;o<e+n;o++)for(var i=t;i<t+r;i++)u[o][i]=!0}(r,t,n.rowspan(),n.colspan()),[ae.detailnew(e.element(),n.rowspan(),n.colspan(),e.isNew())]}return[]});return ae.rowdetails(t,e.section())})},li=function(e,t,n){for(var r=[],o=0;o<e.grid().rows();o++){for(var i=[],u=0;u<e.grid().columns();u++){var a=$t.getAt(e,o,u).map(function(e){return ae.elementnew(e.element(),n)}).getOrThunk(function(){return ae.elementnew(t.gap(),!0)});i.push(a)}var c=ae.rowcells(i,e.all()[o].section());r.push(c)}return r},fi=function(e,t,n,r){n===r?xt(e,t):vt(e,t,n)},si=function(o,e){var i=[],u=[],t=function(e,t){0<e.length?function(e,t){var n=Lt(o,t).getOrThunk(function(){var e=le.fromTag(t,et(o).dom());return fn(o,e),e});gn(n);var r=E(e,function(e){e.isNew()&&i.push(e.element());var t=e.element();return gn(t),A(e.cells(),function(e){e.isNew()&&u.push(e.element()),fi(e.element(),"colspan",e.colspan(),1),fi(e.element(),"rowspan",e.rowspan(),1),fn(t,e.element())}),t});mn(n,r)}(e,t):Lt(o,t).each(hn)},n=[],r=[],a=[];return A(e,function(e){switch(e.section()){case"thead":n.push(e);break;case"tbody":r.push(e);break;case"tfoot":a.push(e)}}),t(n,"thead"),t(r,"tbody"),t(a,"tfoot"),{newRows:C(i),newCells:C(u)}},di=function(e){return E(e,function(e){var n=yn(e.element());return A(e.cells(),function(e){var t=xn(e.element());fi(t,"colspan",e.colspan(),1),fi(t,"rowspan",e.rowspan(),1),fn(n,t)}),n})},mi=function(e,t){for(var n=[],r=0;r<e;r++)n.push(t(r));return n},gi=function(e,t){for(var n=[],r=e;r<t;r++)n.push(r);return n},hi=function(t,n){if(n<0||n>=t.length-1)return S.none();var e=t[n].fold(function(){var e=U(t.slice(0,n));return ni(e,function(e,t){return e.map(function(e){return{value:e,delta:t+1}})})},function(e){return S.some({value:e,delta:0})}),r=t[n+1].fold(function(){var e=t.slice(n+1);return ni(e,function(e,t){return e.map(function(e){return{value:e,delta:t+1}})})},function(e){return S.some({value:e,delta:1})});return e.bind(function(n){return r.map(function(e){var t=e.delta+n.delta;return Math.abs(e.value-n.value)/t})})},pi=function(e,t,n){var r=e();return W(r,t).orThunk(function(){return S.from(r[0]).orThunk(n)}).map(function(e){return e.element()})},vi=function(n){var e=n.grid(),t=gi(0,e.columns()),r=gi(0,e.rows());return E(t,function(t){return pi(function(){return j(r,function(e){return $t.getAt(n,e,t).filter(function(e){return e.column()===t}).fold(C([]),function(e){return[e]})})},function(e){return 1===e.colspan()},function(){return $t.getAt(n,0,t)})})},bi=function(n){var e=n.grid(),t=gi(0,e.rows()),r=gi(0,e.columns());return E(t,function(t){return pi(function(){return j(r,function(e){return $t.getAt(n,t,e).filter(function(e){return e.row()===t}).fold(C([]),function(e){return[e]})})},function(e){return 1===e.rowspan()},function(){return $t.getAt(n,t,0)})})},wi=function(e,t,n,r,o){var i=le.fromTag("div");return tn(i,{position:"absolute",left:t-r/2+"px",top:n+"px",height:o+"px",width:r+"px"}),bt(i,{"data-column":e,role:"presentation"}),i},yi=function(e,t,n,r,o){var i=le.fromTag("div");return tn(i,{position:"absolute",left:t+"px",top:n-o/2+"px",height:o+"px",width:r+"px"}),bt(i,{"data-row":e,role:"presentation"}),i},xi=function(e){var t=e.replace(/\./g,"-");return{resolve:function(e){return t+"-"+e}}},Ci={resolve:xi("ephox-snooker").resolve},Ri=function(e,t){var n=wt(e,t);return n===undefined||""===n?[]:n.split(" ")},Si=function(e){return e.dom().classList!==undefined},Ti=function(e,t){return o=t,i=Ri(n=e,r="class").concat([o]),vt(n,r,i.join(" ")),!0;var n,r,o,i},Di=function(e,t){return o=t,0<(i=P(Ri(n=e,r="class"),function(e){return e!==o})).length?vt(n,r,i.join(" ")):xt(n,r),!1;var n,r,o,i},Oi=function(e,t){Si(e)?e.dom().classList.add(t):Ti(e,t)},ki=function(e){0===(Si(e)?e.dom().classList:Ri(e,"class")).length&&xt(e,"class")},Ni=function(e,t){return Si(e)&&e.dom().classList.contains(t)},Ei=Ci.resolve("resizer-bar"),Ai=Ci.resolve("resizer-rows"),Pi=Ci.resolve("resizer-cols"),Ii=function(e){var t=Nt(e.parent(),"."+Ei);A(t,hn)},Bi=function(n,e,r){var o=n.origin();A(e,function(e,t){e.each(function(e){var t=r(o,e);Oi(t,Ei),fn(n.parent(),t)})})},Wi=function(e,t,n,r,o,i){var u,a,c,l,f=po(t),s=0<n.length?o.positions(n,t):[];u=e,a=s,c=f,l=$r(t),Bi(u,a,function(e,t){var n=yi(t.row(),c.left()-e.left(),t.y()-e.top(),l,7);return Oi(n,Ai),n});var d,m,g,h,p=0<r.length?i.positions(r,t):[];d=e,m=p,g=f,h=Xr(t),Bi(d,m,function(e,t){var n=wi(t.col(),t.x()-e.left(),g.top()-e.top(),7,h);return Oi(n,Pi),n})},Mi=function(e,t){var n=Nt(e.parent(),"."+Ei);A(n,t)},_i={refresh:function(e,t,n,r){Ii(e);var o=Yt(t),i=$t.generate(o),u=bi(i),a=vi(i);Wi(e,t,u,a,n,r)},hide:function(e){Mi(e,function(e){en(e,"display","none")})},show:function(e){Mi(e,function(e){en(e,"display","block")})},destroy:Ii,isRowBar:function(e){return Ni(e,Ai)},isColBar:function(e){return Ni(e,Pi)}},Li=function(e,r){return E(e,function(e){var t,n=(t=e.details(),ni(t,function(e){return tt(e.element()).map(function(e){var t=tt(e).isNone();return ae.elementnew(e,t)})}).getOrThunk(function(){return ae.elementnew(r.row(),!0)}));return ae.rowdatanew(n.element(),e.details(),e.section(),n.isNew())})},Fi=function(e,t){var n=ci(e,$e);return Li(n,t)},ji=function(e,t){var n=F(E(e.all(),function(e){return e.cells()}));return W(n,function(e){return $e(t,e.element())})},zi=function(a,c,l,f,s){return function(n,r,e,o,i){var t=Yt(r),u=$t.generate(t);return c(u,e).map(function(e){var t=li(u,o,!1),n=a(t,e,$e,s(o)),r=Fi(n.grid(),o);return{grid:C(r),cursor:n.cursor}}).fold(function(){return S.none()},function(e){var t=si(r,e.grid());return l(r,e.grid(),i),f(r),_i.refresh(n,r,ko.height,i),S.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})})}},Hi=Fi,Ui=function(t,e){return Gt.cell(e.element()).bind(function(e){return ji(t,e)})},qi=function(t,e){var n=E(e.selection(),function(e){return Gt.cell(e).bind(function(e){return ji(t,e)})}),r=ti(n);return 0<r.length?S.some(r):S.none()},Vi=function(t,n){return Gt.cell(n.element()).bind(function(e){return ji(t,e).map(function(e){return ei(e,{generators:n.generators,clipboard:n.clipboard})})})},Gi=function(t,e){var n=E(e.selection(),function(e){return Gt.cell(e).bind(function(e){return ji(t,e)})}),r=ti(n);return 0<r.length?S.some(ei({cells:r},{generators:e.generators,clipboard:e.clipboard})):S.none()},Yi=function(e,t){return t.mergable()},Xi=function(e,t){return t.unmergable()},Ki=function(n){return{is:function(e){return n===e},isValue:l,isError:a,getOr:C(n),getOrThunk:C(n),getOrDie:C(n),or:function(e){return Ki(n)},orThunk:function(e){return Ki(n)},fold:function(e,t){return t(n)},map:function(e){return Ki(e(n))},each:function(e){e(n)},bind:function(e){return e(n)},exists:function(e){return e(n)},forall:function(e){return e(n)},toOption:function(){return S.some(n)}}},Ji=function(n){return{is:a,isValue:a,isError:l,getOr:u,getOrThunk:function(e){return e()},getOrDie:function(){return e=String(n),function(){throw new Error(e)}();var e},or:function(e){return e},orThunk:function(e){return e()},fold:function(e,t){return e(n)},map:function(e){return Ji(n)},each:y,bind:function(e){return Ji(n)},exists:a,forall:l,toOption:S.none}},$i={value:Ki,error:Ji},Qi=function(e,t){return E(e,function(){return ae.elementnew(t.cell(),!0)})},Zi=function(t,e,n){return t.concat(mi(e,function(e){return ii.setCells(t[t.length-1],Qi(t[t.length-1].cells(),n))}))},eu=function(e,t,n){return E(e,function(e){return ii.setCells(e,e.cells().concat(Qi(gi(0,t),n)))})},tu=function(e,t,n){if(e.row()>=t.length||e.column()>ii.cellLength(t[0]))return $i.error("invalid start address out of table bounds, row: "+e.row()+", column: "+e.column());var r=t.slice(e.row()),o=r[0].cells().slice(e.column()),i=ii.cellLength(n[0]),u=n.length;return $i.value({rowDelta:C(r.length-u),colDelta:C(o.length-i)})},nu=function(e,t){var n=ii.cellLength(e[0]),r=ii.cellLength(t[0]);return{rowDelta:C(0),colDelta:C(n-r)}},ru=function(e,t,n){var r=t.colDelta()<0?eu:u;return(t.rowDelta()<0?Zi:u)(r(e,Math.abs(t.colDelta()),n),Math.abs(t.rowDelta()),n)},ou=function(e,t,n,r){if(0===e.length)return e;for(var o=t.startRow();o<=t.finishRow();o++)for(var i=t.startCol();i<=t.finishCol();i++)ii.mutateCell(e[o],i,ae.elementnew(r(),!1));return e},iu=function(e,t,n,r){for(var o=!0,i=0;i<e.length;i++)for(var u=0;u<ii.cellLength(e[0]);u++){var a=n(ii.getCellElement(e[i],u),t);!0===a&&!1===o?ii.mutateCell(e[i],u,ae.elementnew(r(),!0)):!0===a&&(o=!1)}return e},uu=function(i,u,a,c){if(0<u&&u<i.length){var e=i[u-1].cells(),t=(n=a,B(e,function(e,t){return N(e,function(e){return n(e.element(),t.element())})?e:e.concat([t])},[]));A(t,function(e){for(var t=S.none(),n=u;n<i.length;n++)for(var r=0;r<ii.cellLength(i[0]);r++){var o=i[n].cells()[r];a(o.element(),e.element())&&(t.isNone()&&(t=S.some(c())),t.each(function(e){ii.mutateCell(i[n],r,ae.elementnew(e,!0))}))}})}var n;return i},au=function(n,r,o,i,u){return tu(n,r,o).map(function(e){var t=ru(r,e,i);return function(e,t,n,r,o){for(var i,u,a,c,l,f,s,d=e.row(),m=e.column(),g=d+n.length,h=m+ii.cellLength(n[0]),p=d;p<g;p++)for(var v=m;v<h;v++){i=t,u=p,a=v,c=o,f=l=void 0,l=ii.getCell(i[u],a),f=R(c,l.element()),s=i[u],1<i.length&&1<ii.cellLength(s)&&(0<a&&f(ii.getCellElement(s,a-1))||a<s.length-1&&f(ii.getCellElement(s,a+1))||0<u&&f(ii.getCellElement(i[u-1],a))||u<i.length-1&&f(ii.getCellElement(i[u+1],a)))&&iu(t,ii.getCellElement(t[p],v),o,r.cell);var b=ii.getCellElement(n[p-d],v-m),w=r.replace(b);ii.mutateCell(t[p],v,ae.elementnew(w,!0))}return t}(n,t,o,i,u)})},cu=function(e,t,n,r,o){uu(t,e,o,r.cell);var i=nu(n,t),u=ru(n,i,r),a=nu(t,u),c=ru(t,a,r);return c.slice(0,e).concat(u).concat(c.slice(e,c.length))},lu=function(n,r,e,o,i){var t=n.slice(0,r),u=n.slice(r),a=ii.mapCells(n[e],function(e,t){return 0<r&&r<n.length&&o(ii.getCellElement(n[r-1],t),ii.getCellElement(n[r],t))?ii.getCell(n[r],t):ae.elementnew(i(e.element(),o),!0)});return t.concat([a]).concat(u)},fu=function(e,n,r,o,i){return E(e,function(e){var t=0<n&&n<ii.cellLength(e)&&o(ii.getCellElement(e,n-1),ii.getCellElement(e,n))?ii.getCell(e,n):ae.elementnew(i(ii.getCellElement(e,r),o),!0);return ii.addCell(e,n,t)})},su=function(e,r,o,i,u){var a=o+1;return E(e,function(e,t){var n=t===r?ae.elementnew(u(ii.getCellElement(e,o),i),!0):ii.getCell(e,o);return ii.addCell(e,a,n)})},du=function(e,t,n,r,o){var i=t+1,u=e.slice(0,i),a=e.slice(i),c=ii.mapCells(e[t],function(e,t){return t===n?ae.elementnew(o(e.element(),r),!0):e});return u.concat([c]).concat(a)},mu=function(e,t,n){return e.slice(0,t).concat(e.slice(n+1))},gu=function(e,n,r){var t=E(e,function(e){var t=e.cells().slice(0,n).concat(e.cells().slice(r+1));return ae.rowcells(t,e.section())});return P(t,function(e){return 0<e.cells().length})},hu=function(e,n,r,o){return E(e,function(e){return ii.mapCells(e,function(e){return t=e,N(n,function(e){return r(t.element(),e.element())})?ae.elementnew(o(e.element(),r),!0):e;var t})})},pu=function(e,t,n,r){return ii.getCellElement(e[t],n)!==undefined&&0<t&&r(ii.getCellElement(e[t-1],n),ii.getCellElement(e[t],n))},vu=function(e,t,n){return 0<t&&n(ii.getCellElement(e,t-1),ii.getCellElement(e,t))},bu=function(n,r,o,e){var t=j(n,function(e,t){return pu(n,t,r,o)||vu(e,r,o)?[]:[ii.getCell(e,r)]});return hu(n,t,o,e)},wu=function(n,r,o,e){var i=n[r],t=j(i.cells(),function(e,t){return pu(n,r,t,o)||vu(i,t,o)?[]:[e]});return hu(n,t,o,e)},yu=function(e){return{fold:e}},xu=function(){return yu(function(e,t,n,r,o){return e()})},Cu=function(i){return yu(function(e,t,n,r,o){return t(i)})},Ru=function(i,u){return yu(function(e,t,n,r,o){return n(i,u)})},Su=function(i,u,a){return yu(function(e,t,n,r,o){return r(i,u,a)})},Tu=function(i,u){return yu(function(e,t,n,r,o){return o(i,u)})},Du=function(e,t,i,u){var n,r,a=e.slice(0),o=(r=t,0===(n=e).length?xu():1===n.length?Cu(0):0===r?Ru(0,1):r===n.length-1?Tu(r-1,r):0<r&&r<n.length-1?Su(r-1,r,r+1):xu()),c=function(e){return E(e,C(0))},l=C(c(a)),f=function(e,t){if(0<=i){var n=Math.max(u.minCellWidth(),a[t]-i);return c(a.slice(0,e)).concat([i,n-a[t]]).concat(c(a.slice(t+1)))}var r=Math.max(u.minCellWidth(),a[e]+i),o=a[e]-r;return c(a.slice(0,e)).concat([r-a[e],o]).concat(c(a.slice(t+1)))},s=f;return o.fold(l,function(e){return u.singleColumnWidth(a[e],i)},s,function(e,t,n){return f(t,n)},function(e,t){if(0<=i)return c(a.slice(0,t)).concat([i]);var n=Math.max(u.minCellWidth(),a[t]+i);return c(a.slice(0,t)).concat([n-a[t]])})},Ou=function(e,t){return yt(e,t)&&1<parseInt(wt(e,t),10)},ku={hasColspan:function(e){return Ou(e,"colspan")},hasRowspan:function(e){return Ou(e,"rowspan")},minWidth:C(10),minHeight:C(10),getInt:function(e,t){return parseInt(nn(e,t),10)}},Nu=function(e,t,n){return on(e,t).fold(function(){return n(e)+"px"},function(e){return e})},Eu=function(e){return Nu(e,"width",fo.getPixelWidth)},Au=function(e){return Nu(e,"height",fo.getHeight)},Pu=function(e,t,n,r,o){var i=vi(e),u=E(i,function(e){return e.map(t.edge)});return E(i,function(e,t){return e.filter(m(ku.hasColspan)).fold(function(){var e=hi(u,t);return r(e)},function(e){return n(e,o)})})},Iu=function(e){return e.map(function(e){return e+"px"}).getOr("")},Bu=function(e,t,n,r){var o=bi(e),i=E(o,function(e){return e.map(t.edge)});return E(o,function(e,t){return e.filter(m(ku.hasRowspan)).fold(function(){var e=hi(i,t);return r(e)},function(e){return n(e)})})},Wu={getRawWidths:function(e,t){return Pu(e,t,Eu,Iu)},getPixelWidths:function(e,t,n){return Pu(e,t,fo.getPixelWidth,function(e){return e.getOrThunk(n.minCellWidth)},n)},getPercentageWidths:function(e,t,n){return Pu(e,t,fo.getPercentageWidth,function(e){return e.fold(function(){return n.minCellWidth()},function(e){return e/n.pixelWidth()*100})},n)},getPixelHeights:function(e,t){return Bu(e,t,fo.getHeight,function(e){return e.getOrThunk(ku.minHeight)})},getRawHeights:function(e,t){return Bu(e,t,Au,Iu)}},Mu=function(e,t,n){for(var r=0,o=e;o<t;o++)r+=n[o]!==undefined?n[o]:0;return r},_u=function(e,n){var t=$t.justCells(e);return E(t,function(e){var t=Mu(e.column(),e.column()+e.colspan(),n);return{element:e.element,width:C(t),colspan:e.colspan}})},Lu=function(e,n){var t=$t.justCells(e);return E(t,function(e){var t=Mu(e.row(),e.row()+e.rowspan(),n);return{element:e.element,height:C(t),rowspan:e.rowspan}})},Fu=function(e,n){return E(e.all(),function(e,t){return{element:e.element,height:C(n[t])}})},ju=function(e){var t=parseInt(e,10),n=u;return{width:C(t),pixelWidth:C(t),getWidths:Wu.getPixelWidths,getCellDelta:n,singleColumnWidth:function(e,t){return[Math.max(ku.minWidth(),e+t)-e]},minCellWidth:ku.minWidth,setElementWidth:fo.setPixelWidth,setTableWidth:function(e,t,n){var r=I(t,function(e,t){return e+t},0);fo.setPixelWidth(e,r)}}},zu=function(e,t){if(fo.percentageBasedSizeRegex().test(t)){var n=fo.percentageBasedSizeRegex().exec(t);return o=n[1],i=e,u=parseFloat(o),a=Jr(i),{width:C(u),pixelWidth:C(a),getWidths:Wu.getPercentageWidths,getCellDelta:function(e){return e/a*100},singleColumnWidth:function(e,t){return[100-e]},minCellWidth:function(){return ku.minWidth()/a*100},setElementWidth:fo.setPercentageWidth,setTableWidth:function(e,t,n){var r=u+n;fo.setPercentageWidth(e,r)}}}if(fo.pixelBasedSizeRegex().test(t)){var r=fo.pixelBasedSizeRegex().exec(t);return ju(r[1])}var o,i,u,a,c=Jr(e);return ju(c)},Hu=function(t){return fo.getRawWidth(t).fold(function(){var e=Jr(t);return ju(e)},function(e){return zu(t,e)})},Uu=function(e){return $t.generate(e)},qu=function(e){var t=Yt(e);return Uu(t)},Vu=function(e,t,n,r){var o=Hu(e),i=o.getCellDelta(t),u=qu(e),a=o.getWidths(u,r,o),c=Du(a,n,i,o),l=E(c,function(e,t){return e+a[t]}),f=_u(u,l);A(f,function(e){o.setElementWidth(e.element(),e.width())}),n===u.grid().columns()-1&&o.setTableWidth(e,l,i)},Gu=function(e,n,r,t){var o=qu(e),i=Wu.getPixelHeights(o,t),u=E(i,function(e,t){return r===t?Math.max(n+e,ku.minHeight()):e}),a=Lu(o,u),c=Fu(o,u);A(c,function(e){fo.setHeight(e.element(),e.height())}),A(a,function(e){fo.setHeight(e.element(),e.height())});var l=I(u,function(e,t){return e+t},0);fo.setHeight(e,l)},Yu=function(e,t,n){var r=Hu(e),o=Uu(t),i=r.getWidths(o,n,r),u=_u(o,i);A(u,function(e){r.setElementWidth(e.element(),e.width())});var a=I(i,function(e,t){return t+e},0);0<u.length&&r.setElementWidth(e,a)},Xu=function(e){0===Gt.cells(e).length&&hn(e)},Ku=X("grid","cursor"),Ju=function(e,t,n){return $u(e,t,n).orThunk(function(){return $u(e,0,0)})},$u=function(e,t,n){return S.from(e[t]).bind(function(e){return S.from(e.cells()[n]).bind(function(e){return S.from(e.element())})})},Qu=function(e,t,n){return Ku(e,$u(e,t,n))},Zu=function(e){return B(e,function(e,t){return N(e,function(e){return e.row()===t.row()})?e:e.concat([t])},[]).sort(function(e,t){return e.row()-t.row()})},ea=function(e){return B(e,function(e,t){return N(e,function(e){return e.column()===t.column()})?e:e.concat([t])},[]).sort(function(e,t){return e.column()-t.column()})},ta=function(e,t,n){var r=Xt(e,n),o=$t.generate(r);return li(o,t,!0)},na=Yu,ra={insertRowBefore:zi(function(e,t,n,r){var o=t.row(),i=t.row(),u=lu(e,i,o,n,r.getOrInit);return Qu(u,i,t.column())},Ui,y,y,Fo),insertRowsBefore:zi(function(e,t,n,r){var o=t[0].row(),i=t[0].row(),u=Zu(t),a=B(u,function(e,t){return lu(e,i,o,n,r.getOrInit)},e);return Qu(a,i,t[0].column())},qi,y,y,Fo),insertRowAfter:zi(function(e,t,n,r){var o=t.row(),i=t.row()+t.rowspan(),u=lu(e,i,o,n,r.getOrInit);return Qu(u,i,t.column())},Ui,y,y,Fo),insertRowsAfter:zi(function(e,t,n,r){var o=Zu(t),i=o[o.length-1].row(),u=o[o.length-1].row()+o[o.length-1].rowspan(),a=B(o,function(e,t){return lu(e,u,i,n,r.getOrInit)},e);return Qu(a,u,t[0].column())},qi,y,y,Fo),insertColumnBefore:zi(function(e,t,n,r){var o=t.column(),i=t.column(),u=fu(e,i,o,n,r.getOrInit);return Qu(u,t.row(),i)},Ui,na,y,Fo),insertColumnsBefore:zi(function(e,t,n,r){var o=ea(t),i=o[0].column(),u=o[0].column(),a=B(o,function(e,t){return fu(e,u,i,n,r.getOrInit)},e);return Qu(a,t[0].row(),u)},qi,na,y,Fo),insertColumnAfter:zi(function(e,t,n,r){var o=t.column(),i=t.column()+t.colspan(),u=fu(e,i,o,n,r.getOrInit);return Qu(u,t.row(),i)},Ui,na,y,Fo),insertColumnsAfter:zi(function(e,t,n,r){var o=t[t.length-1].column(),i=t[t.length-1].column()+t[t.length-1].colspan(),u=ea(t),a=B(u,function(e,t){return fu(e,i,o,n,r.getOrInit)},e);return Qu(a,t[0].row(),i)},qi,na,y,Fo),splitCellIntoColumns:zi(function(e,t,n,r){var o=su(e,t.row(),t.column(),n,r.getOrInit);return Qu(o,t.row(),t.column())},Ui,y,y,Fo),splitCellIntoRows:zi(function(e,t,n,r){var o=du(e,t.row(),t.column(),n,r.getOrInit);return Qu(o,t.row(),t.column())},Ui,y,y,Fo),eraseColumns:zi(function(e,t,n,r){var o=ea(t),i=gu(e,o[0].column(),o[o.length-1].column()),u=Ju(i,t[0].row(),t[0].column());return Ku(i,u)},qi,na,Xu,Fo),eraseRows:zi(function(e,t,n,r){var o=Zu(t),i=mu(e,o[0].row(),o[o.length-1].row()),u=Ju(i,t[0].row(),t[0].column());return Ku(i,u)},qi,y,Xu,Fo),makeColumnHeader:zi(function(e,t,n,r){var o=bu(e,t.column(),n,r.replaceOrInit);return Qu(o,t.row(),t.column())},Ui,y,y,jo("row","th")),unmakeColumnHeader:zi(function(e,t,n,r){var o=bu(e,t.column(),n,r.replaceOrInit);return Qu(o,t.row(),t.column())},Ui,y,y,jo(null,"td")),makeRowHeader:zi(function(e,t,n,r){var o=wu(e,t.row(),n,r.replaceOrInit);return Qu(o,t.row(),t.column())},Ui,y,y,jo("col","th")),unmakeRowHeader:zi(function(e,t,n,r){var o=wu(e,t.row(),n,r.replaceOrInit);return Qu(o,t.row(),t.column())},Ui,y,y,jo(null,"td")),mergeCells:zi(function(e,t,n,r){var o=t.cells();Qo(o);var i=ou(e,t.bounds(),n,C(o[0]));return Ku(i,S.from(o[0]))},Yi,y,y,zo),unmergeCells:zi(function(e,t,n,r){var o=I(t,function(e,t){return iu(e,t,n,r.combine(t))},e);return Ku(o,S.from(t[0]))},Xi,y,y,zo),pasteCells:zi(function(e,n,t,r){var o,i,u,a,c=(o=n.clipboard(),i=n.generators(),u=Yt(o),a=$t.generate(u),li(a,i,!0)),l=ae.address(n.row(),n.column());return au(l,e,c,n.generators(),t).fold(function(){return Ku(e,S.some(n.element()))},function(e){var t=Ju(e,n.row(),n.column());return Ku(e,t)})},Vi,na,y,Fo),pasteRowsBefore:zi(function(e,t,n,r){var o=e[t.cells[0].row()],i=t.cells[0].row(),u=ta(t.clipboard(),t.generators(),o),a=cu(i,e,u,t.generators(),n),c=Ju(a,t.cells[0].row(),t.cells[0].column());return Ku(a,c)},Gi,y,y,Fo),pasteRowsAfter:zi(function(e,t,n,r){var o=e[t.cells[0].row()],i=t.cells[t.cells.length-1].row()+t.cells[t.cells.length-1].rowspan(),u=ta(t.clipboard(),t.generators(),o),a=cu(i,e,u,t.generators(),n),c=Ju(a,t.cells[0].row(),t.cells[0].column());return Ku(a,c)},Gi,y,y,Fo)},oa=function(e){return le.fromDom(e.getBody())},ia=function(e){return e.getBoundingClientRect().width},ua=function(e){return e.getBoundingClientRect().height},aa=function(t){return function(e){return $e(e,oa(t))}},ca=function(e){return/^[0-9]+$/.test(e)&&(e+="px"),e},la=function(e){var t=Nt(e,"td[data-mce-style],th[data-mce-style]");xt(e,"data-mce-style"),A(t,function(e){xt(e,"data-mce-style")})},fa={isRtl:C(!1)},sa={isRtl:C(!0)},da={directionAt:function(e){return"rtl"==("rtl"===nn(e,"direction")?"rtl":"ltr")?sa:fa}},ma=["tableprops","tabledelete","|","tableinsertrowbefore","tableinsertrowafter","tabledeleterow","|","tableinsertcolbefore","tableinsertcolafter","tabledeletecol"],ga={"border-collapse":"collapse",width:"100%"},ha={border:"1"},pa=function(e){return e.getParam("table_cell_advtab",!0,"boolean")},va=function(e){return e.getParam("table_row_advtab",!0,"boolean")},ba=function(e){return e.getParam("table_advtab",!0,"boolean")},wa=function(e){return e.getParam("table_style_by_css",!1,"boolean")},ya=function(e){return e.getParam("table_cell_class_list",[],"array")},xa=function(e){return e.getParam("table_row_class_list",[],"array")},Ca=function(e){return e.getParam("table_class_list",[],"array")},Ra=function(e){return!1===e.getParam("table_responsive_width")},Sa=function(e,t){return e.fire("newrow",{node:t})},Ta=function(e,t){return e.fire("newcell",{node:t})},Da=function(e,t,n,r){e.fire("ObjectResizeStart",{target:t,width:n,height:r})},Oa=function(e,t,n,r){e.fire("ObjectResized",{target:t,width:n,height:r})},ka=function(f,e){var t,n=function(e){return"table"===lt(oa(e))},s=(t=f.getParam("table_clone_elements"),v(t)?S.some(t.split(/[ ,]/)):Array.isArray(t)?S.some(t):S.none()),r=function(u,a,c,l){return function(e,t){la(e);var n=l(),r=le.fromDom(f.getDoc()),o=Eo(da.directionAt),i=_n(c,r,s);return a(e)?u(n,e,t,i,o).bind(function(e){return A(e.newRows(),function(e){Sa(f,e.dom())}),A(e.newCells(),function(e){Ta(f,e.dom())}),e.cursor().map(function(e){var t=f.dom.createRng();return t.setStart(e.dom(),0),t.setEnd(e.dom(),0),t})}):S.none()}};return{deleteRow:r(ra.eraseRows,function(e){var t=Po(e);return!1===n(f)||1<t.rows()},y,e),deleteColumn:r(ra.eraseColumns,function(e){var t=Po(e);return!1===n(f)||1<t.columns()},y,e),insertRowsBefore:r(ra.insertRowsBefore,l,y,e),insertRowsAfter:r(ra.insertRowsAfter,l,y,e),insertColumnsBefore:r(ra.insertColumnsBefore,l,so,e),insertColumnsAfter:r(ra.insertColumnsAfter,l,so,e),mergeCells:r(ra.mergeCells,l,y,e),unmergeCells:r(ra.unmergeCells,l,y,e),pasteRowsBefore:r(ra.pasteRowsBefore,l,y,e),pasteRowsAfter:r(ra.pasteRowsAfter,l,y,e),pasteCells:r(ra.pasteCells,l,y,e)}},Na=function(e,t,r){var n=Yt(e),o=$t.generate(n);return qi(o,t).map(function(e){var t=li(o,r,!1).slice(e[0].row(),e[e.length-1].row()+e[e.length-1].rowspan()),n=Hi(t,r);return di(n)})},Ea=tinymce.util.Tools.resolve("tinymce.util.Tools"),Aa=function(e,t,n){n&&e.formatter.apply("align"+n,{},t)},Pa=function(e,t,n){n&&e.formatter.apply("valign"+n,{},t)},Ia=function(t,n){Ea.each("left center right".split(" "),function(e){t.formatter.remove("align"+e,{},n)})},Ba=function(t,n){Ea.each("top middle bottom".split(" "),function(e){t.formatter.remove("valign"+e,{},n)})},Wa=function(o,e,i){var t;return t=function(e,t){for(var n=0;n<t.length;n++){var r=o.getStyle(t[n],i);if(void 0===e&&(e=r),e!==r)return""}return e}(t,o.select("td,th",e))},Ma=function(e,t){var n=e.dom,r=t.control.rootControl,o=r.toJSON(),i=n.parseStyle(o.style);i["border-style"]=o.borderStyle,i["border-color"]=o.borderColor,i["background-color"]=o.backgroundColor,i.width=o.width?ca(o.width):"",i.height=o.height?ca(o.height):"",r.find("#style").value(n.serializeStyle(n.parseStyle(n.serializeStyle(i))))},_a=function(e,t){var n=e.dom,r=t.control.rootControl,o=r.toJSON(),i=n.parseStyle(o.style);r.find("#borderStyle").value(i["border-style"]||""),r.find("#borderColor").value(i["border-color"]||""),r.find("#backgroundColor").value(i["background-color"]||""),r.find("#width").value(i.width||""),r.find("#height").value(i.height||"")},La={createStyleForm:function(n){var e=function(){var e=n.getParam("color_picker_callback");if(e)return function(t){return e.call(n,function(e){t.control.value(e).fire("change")},t.control.value())}};return{title:"Advanced",type:"form",defaults:{onchange:R(Ma,n)},items:[{label:"Style",name:"style",type:"textbox",onchange:R(_a,n)},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border style",type:"listbox",name:"borderStyle",width:90,onselect:R(Ma,n),values:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]},{label:"Border color",type:"colorbox",name:"borderColor",onaction:e()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:e()}]}]}},buildListItems:function(e,r,t){var o=function(e,n){return n=n||[],Ea.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=o(e.menu):(t.value=e.value,r&&r(t)),n.push(t)}),n};return o(e,t||[])},updateStyleField:Ma,extractAdvancedStyles:function(e,t){var n=e.parseStyle(e.getAttrib(t,"style")),r={};return n["border-style"]&&(r.borderStyle=n["border-style"]),n["border-color"]&&(r.borderColor=n["border-color"]),n["background-color"]&&(r.backgroundColor=n["background-color"]),r.style=e.serializeStyle(n),r},updateAdvancedFields:_a,syncAdvancedStyleFields:function(e,t){t.control.rootControl.find("#style")[0].getEl().isEqualNode(document.activeElement)?_a(e,t):Ma(e,t)}},Fa=function(r,o,e){var i,u=r.dom;function a(e,t,n){(1===o.length||n)&&u.setAttrib(e,t,n)}function c(e,t,n){(1===o.length||n)&&u.setStyle(e,t,n)}pa(r)&&La.syncAdvancedStyleFields(r,e),i=e.control.rootControl.toJSON(),r.undoManager.transact(function(){Ea.each(o,function(e){var t,n;a(e,"scope",i.scope),1===o.length?a(e,"style",i.style):(t=e,n=i.style,delete t.dataset.mceStyle,t.style.cssText+=";"+n),a(e,"class",i["class"]),c(e,"width",ca(i.width)),c(e,"height",ca(i.height)),i.type&&e.nodeName.toLowerCase()!==i.type&&(e=u.rename(e,i.type)),1===o.length&&(Ia(r,e),Ba(r,e)),i.align&&Aa(r,e,i.align),i.valign&&Pa(r,e,i.valign)}),r.focus()})},ja=function(t){var e,n,r,o=[];if(o=t.dom.select("td[data-mce-selected],th[data-mce-selected]"),e=t.dom.getParent(t.selection.getStart(),"td,th"),!o.length&&e&&o.push(e),e=e||o[0]){var i,u,a,c;1<o.length?n={width:"",height:"",scope:"","class":"",align:"",valign:"",style:"",type:e.nodeName.toLowerCase()}:(u=e,a=(i=t).dom,c={width:a.getStyle(u,"width")||a.getAttrib(u,"width"),height:a.getStyle(u,"height")||a.getAttrib(u,"height"),scope:a.getAttrib(u,"scope"),"class":a.getAttrib(u,"class"),type:u.nodeName.toLowerCase(),style:"",align:"",valign:""},Ea.each("left center right".split(" "),function(e){i.formatter.matchNode(u,"align"+e)&&(c.align=e)}),Ea.each("top middle bottom".split(" "),function(e){i.formatter.matchNode(u,"valign"+e)&&(c.valign=e)}),pa(i)&&Ea.extend(c,La.extractAdvancedStyles(a,u)),n=c),0<ya(t).length&&(r={name:"class",type:"listbox",label:"Class",values:La.buildListItems(ya(t),function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({block:"td",classes:[e.value]})})})});var l={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",layout:"grid",columns:2,labelGapCalc:!1,padding:0,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width",onchange:R(La.updateStyleField,t)},{label:"Height",name:"height",onchange:R(La.updateStyleField,t)},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},r]};pa(t)?t.windowManager.open({title:"Cell properties",bodyType:"tabpanel",data:n,body:[{title:"General",type:"form",items:l},La.createStyleForm(t)],onsubmit:R(Fa,t,o)}):t.windowManager.open({title:"Cell properties",data:n,body:l,onsubmit:R(Fa,t,o)})}};function za(f,s,d,e){var m=f.dom;function g(e,t,n){(1===s.length||n)&&m.setAttrib(e,t,n)}va(f)&&La.syncAdvancedStyleFields(f,e);var h=e.control.rootControl.toJSON();f.undoManager.transact(function(){Ea.each(s,function(e){var t,n,r,o,i,u,a,c,l;g(e,"scope",h.scope),g(e,"style",h.style),g(e,"class",h["class"]),t=e,n="height",r=ca(h.height),(1===s.length||r)&&m.setStyle(t,n,r),h.type!==e.parentNode.nodeName.toLowerCase()&&(o=f.dom,i=e,u=h.type,a=o.getParent(i,"table"),c=i.parentNode,(l=o.select(u,a)[0])||(l=o.create(u),a.firstChild?"CAPTION"===a.firstChild.nodeName?o.insertAfter(l,a.firstChild):a.insertBefore(l,a.firstChild):a.appendChild(l)),l.appendChild(i),c.hasChildNodes()||o.remove(c)),h.align!==d.align&&(Ia(f,e),Aa(f,e,h.align))}),f.focus()})}var Ha=function(t){var e,n,r,o,i,u,a,c,l,f,s=t.dom,d=[];e=s.getParent(t.selection.getStart(),"table"),n=s.getParent(t.selection.getStart(),"td,th"),Ea.each(e.rows,function(t){Ea.each(t.cells,function(e){if(s.getAttrib(e,"data-mce-selected")||e===n)return d.push(t),!1})}),(r=d[0])&&(1<d.length?i={height:"",scope:"",style:"","class":"",align:"",type:r.parentNode.nodeName.toLowerCase()}:(c=r,l=(a=t).dom,f={height:l.getStyle(c,"height")||l.getAttrib(c,"height"),scope:l.getAttrib(c,"scope"),"class":l.getAttrib(c,"class"),align:"",style:"",type:c.parentNode.nodeName.toLowerCase()},Ea.each("left center right".split(" "),function(e){a.formatter.matchNode(c,"align"+e)&&(f.align=e)}),va(a)&&Ea.extend(f,La.extractAdvancedStyles(l,c)),i=f),0<xa(t).length&&(o={name:"class",type:"listbox",label:"Class",values:La.buildListItems(xa(t),function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({block:"tr",classes:[e.value]})})})}),u={type:"form",columns:2,padding:0,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"Header",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"},o]},va(t)?t.windowManager.open({title:"Row properties",data:i,bodyType:"tabpanel",body:[{title:"General",type:"form",items:u},La.createStyleForm(t)],onsubmit:R(za,t,d,i)}):t.windowManager.open({title:"Row properties",data:i,body:u,onsubmit:R(za,t,d,i)}))},Ua=tinymce.util.Tools.resolve("tinymce.Env"),qa={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},percentages:!0},Va=function(e,t,n,r,o){void 0===o&&(o=qa);var i=le.fromTag("table");tn(i,o.styles),bt(i,o.attributes);var u=le.fromTag("tbody");fn(i,u);for(var a=[],c=0;c<e;c++){for(var l=le.fromTag("tr"),f=0;f<t;f++){var s=c<n||f<r?le.fromTag("th"):le.fromTag("td");f<r&&vt(s,"scope","row"),c<n&&vt(s,"scope","col"),fn(s,le.fromTag("br")),o.percentages&&en(s,"width",100/t+"%"),fn(l,s)}a.push(l)}return mn(u,a),i},Ga=function(e,t){e.selection.select(t.dom(),!0),e.selection.collapse(!0)},Ya=function(r,e,t){var n,o,i=r.getParam("table_default_styles",ga,"object"),u={styles:i,attributes:(o=r,o.getParam("table_default_attributes",ha,"object")),percentages:(n=i.width,v(n)&&-1!==n.indexOf("%")&&!Ra(r))},a=Va(t,e,0,0,u);vt(a,"data-mce-id","__mce");var c,l,f,s=(c=a,l=le.fromTag("div"),f=le.fromDom(c.dom().cloneNode(!0)),fn(l,f),l.dom().innerHTML);return r.insertContent(s),Ft(oa(r),'table[data-mce-id="__mce"]').map(function(e){var t,n;return Ra(r)&&en(e,"width",nn(e,"width")),xt(e,"data-mce-id"),t=r,A(Nt(e,"tr"),function(e){Sa(t,e.dom()),A(Nt(e,"th,td"),function(e){Ta(t,e.dom())})}),n=r,Ft(e,"td,th").each(R(Ga,n)),e.dom()}).getOr(null)};function Xa(e,t,n,r){if("TD"===t.tagName||"TH"===t.tagName)e.setStyle(t,n,r);else if(t.children)for(var o=0;o<t.children.length;o++)Xa(e,t.children[o],n,r)}var Ka=function(e,t,n){var r,o,i=e.dom;ba(e)&&La.syncAdvancedStyleFields(e,n),!1===(o=n.control.rootControl.toJSON())["class"]&&delete o["class"],e.undoManager.transact(function(){t||(t=Ya(e,o.cols||1,o.rows||1)),function(e,t,n){var r,o=e.dom,i={},u={};if(i["class"]=n["class"],u.height=ca(n.height),o.getAttrib(t,"width")&&!wa(e)?i.width=(r=n.width)?r.replace(/px$/,""):"":u.width=ca(n.width),wa(e)?(u["border-width"]=ca(n.border),u["border-spacing"]=ca(n.cellspacing),Ea.extend(i,{"data-mce-border-color":n.borderColor,"data-mce-cell-padding":n.cellpadding,"data-mce-border":n.border})):Ea.extend(i,{border:n.border,cellpadding:n.cellpadding,cellspacing:n.cellspacing}),wa(e)&&t.children)for(var a=0;a<t.children.length;a++)Xa(o,t.children[a],{"border-width":ca(n.border),"border-color":n.borderColor,padding:ca(n.cellpadding)});n.style?Ea.extend(u,o.parseStyle(n.style)):u=Ea.extend({},o.parseStyle(o.getAttrib(t,"style")),u),i.style=o.serializeStyle(u),o.setAttribs(t,i)}(e,t,o),(r=i.select("caption",t)[0])&&!o.caption&&i.remove(r),!r&&o.caption&&((r=i.create("caption")).innerHTML=Ua.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(r,t.firstChild)),Ia(e,t),o.align&&Aa(e,t,o.align),e.focus(),e.addVisual()})},Ja=function(t,e){var n,r,o,i,u,a,c,l,f,s,d=t.dom,m={};!0===e?(n=d.getParent(t.selection.getStart(),"table"))&&(c=n,l=(a=t).dom,f={width:l.getStyle(c,"width")||l.getAttrib(c,"width"),height:l.getStyle(c,"height")||l.getAttrib(c,"height"),cellspacing:l.getStyle(c,"border-spacing")||l.getAttrib(c,"cellspacing"),cellpadding:l.getAttrib(c,"data-mce-cell-padding")||l.getAttrib(c,"cellpadding")||Wa(a.dom,c,"padding"),border:l.getAttrib(c,"data-mce-border")||l.getAttrib(c,"border")||Wa(a.dom,c,"border"),borderColor:l.getAttrib(c,"data-mce-border-color"),caption:!!l.select("caption",c)[0],"class":l.getAttrib(c,"class")},Ea.each("left center right".split(" "),function(e){a.formatter.matchNode(c,"align"+e)&&(f.align=e)}),ba(a)&&Ea.extend(f,La.extractAdvancedStyles(l,c)),m=f):(r={label:"Cols",name:"cols"},o={label:"Rows",name:"rows"}),0<Ca(t).length&&(m["class"]&&(m["class"]=m["class"].replace(/\s*mce\-item\-table\s*/g,"")),i={name:"class",type:"listbox",label:"Class",values:La.buildListItems(Ca(t),function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({block:"table",classes:[e.value]})})})}),u={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",labelGapCalc:!1,padding:0,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:(s=t,s.getParam("table_appearance_options",!0,"boolean")?[r,o,{label:"Width",name:"width",onchange:R(La.updateStyleField,t)},{label:"Height",name:"height",onchange:R(La.updateStyleField,t)},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"}]:[r,o,{label:"Width",name:"width",onchange:R(La.updateStyleField,t)},{label:"Height",name:"height",onchange:R(La.updateStyleField,t)}])},{label:"Alignment",name:"align",type:"listbox",text:"None",values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},i]},ba(t)?t.windowManager.open({title:"Table properties",data:m,bodyType:"tabpanel",body:[{title:"General",type:"form",items:u},La.createStyleForm(t)],onsubmit:R(Ka,t,n)}):t.windowManager.open({title:"Table properties",data:m,body:u,onsubmit:R(Ka,t,n)})},$a=Ea.each,Qa=function(a,t,c,l,n){var r=aa(a),f=function(){return le.fromDom(a.dom.getParent(a.selection.getStart(),"th,td"))},s=function(e){return Gt.table(e,r)},d=function(e){return{width:ia(e.dom()),height:ia(e.dom())}},o=function(t){var n=f();s(n).each(function(i){var e=Ur.forMenu(l,i,n),u=d(i);t(i,e).each(function(e){var t,n,r,o;t=a,n=u,o=d(r=i),n.width===o.width&&n.height===o.height||(Da(t,r.dom(),n.width,n.height),Oa(t,r.dom(),o.width,o.height)),a.selection.setRng(e),a.focus(),c.clear(i),la(i)})})},i=function(e){var o=f();return s(o).bind(function(e){var t=le.fromDom(a.getDoc()),n