wp/wp-includes/js/tinymce/themes/inlite/theme.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   549       return editor.inline ? renderInlineUI(editor, panel) : fail('inlite theme only supports inline mode.');
   549       return editor.inline ? renderInlineUI(editor, panel) : fail('inlite theme only supports inline mode.');
   550     };
   550     };
   551     var Render = { renderUI: renderUI };
   551     var Render = { renderUI: renderUI };
   552 
   552 
   553     var noop = function () {
   553     var noop = function () {
   554       var args = [];
       
   555       for (var _i = 0; _i < arguments.length; _i++) {
       
   556         args[_i] = arguments[_i];
       
   557       }
       
   558     };
   554     };
   559     var constant = function (value) {
   555     var constant = function (value) {
   560       return function () {
   556       return function () {
   561         return value;
   557         return value;
   562       };
   558       };
   563     };
   559     };
   564     var never = constant(false);
   560     var never = constant(false);
   565     var always = constant(true);
   561     var always = constant(true);
   566 
   562 
   567     var never$1 = never;
       
   568     var always$1 = always;
       
   569     var none = function () {
   563     var none = function () {
   570       return NONE;
   564       return NONE;
   571     };
   565     };
   572     var NONE = function () {
   566     var NONE = function () {
   573       var eq = function (o) {
   567       var eq = function (o) {
   576       var call = function (thunk) {
   570       var call = function (thunk) {
   577         return thunk();
   571         return thunk();
   578       };
   572       };
   579       var id = function (n) {
   573       var id = function (n) {
   580         return n;
   574         return n;
   581       };
       
   582       var noop = function () {
       
   583       };
       
   584       var nul = function () {
       
   585         return null;
       
   586       };
       
   587       var undef = function () {
       
   588         return undefined;
       
   589       };
   575       };
   590       var me = {
   576       var me = {
   591         fold: function (n, s) {
   577         fold: function (n, s) {
   592           return n();
   578           return n();
   593         },
   579         },
   594         is: never$1,
   580         is: never,
   595         isSome: never$1,
   581         isSome: never,
   596         isNone: always$1,
   582         isNone: always,
   597         getOr: id,
   583         getOr: id,
   598         getOrThunk: call,
   584         getOrThunk: call,
   599         getOrDie: function (msg) {
   585         getOrDie: function (msg) {
   600           throw new Error(msg || 'error: getOrDie called on none.');
   586           throw new Error(msg || 'error: getOrDie called on none.');
   601         },
   587         },
   602         getOrNull: nul,
   588         getOrNull: constant(null),
   603         getOrUndefined: undef,
   589         getOrUndefined: constant(undefined),
   604         or: id,
   590         or: id,
   605         orThunk: call,
   591         orThunk: call,
   606         map: none,
   592         map: none,
   607         ap: none,
       
   608         each: noop,
   593         each: noop,
   609         bind: none,
   594         bind: none,
   610         flatten: none,
   595         exists: never,
   611         exists: never$1,
   596         forall: always,
   612         forall: always$1,
       
   613         filter: none,
   597         filter: none,
   614         equals: eq,
   598         equals: eq,
   615         equals_: eq,
   599         equals_: eq,
   616         toArray: function () {
   600         toArray: function () {
   617           return [];
   601           return [];
   618         },
   602         },
   619         toString: constant('none()')
   603         toString: constant('none()')
   620       };
   604       };
   621       if (Object.freeze)
   605       if (Object.freeze) {
   622         Object.freeze(me);
   606         Object.freeze(me);
       
   607       }
   623       return me;
   608       return me;
   624     }();
   609     }();
   625     var some = function (a) {
   610     var some = function (a) {
   626       var constant_a = function () {
   611       var constant_a = constant(a);
   627         return a;
       
   628       };
       
   629       var self = function () {
   612       var self = function () {
   630         return me;
   613         return me;
   631       };
       
   632       var map = function (f) {
       
   633         return some(f(a));
       
   634       };
   614       };
   635       var bind = function (f) {
   615       var bind = function (f) {
   636         return f(a);
   616         return f(a);
   637       };
   617       };
   638       var me = {
   618       var me = {
   640           return s(a);
   620           return s(a);
   641         },
   621         },
   642         is: function (v) {
   622         is: function (v) {
   643           return a === v;
   623           return a === v;
   644         },
   624         },
   645         isSome: always$1,
   625         isSome: always,
   646         isNone: never$1,
   626         isNone: never,
   647         getOr: constant_a,
   627         getOr: constant_a,
   648         getOrThunk: constant_a,
   628         getOrThunk: constant_a,
   649         getOrDie: constant_a,
   629         getOrDie: constant_a,
   650         getOrNull: constant_a,
   630         getOrNull: constant_a,
   651         getOrUndefined: constant_a,
   631         getOrUndefined: constant_a,
   652         or: self,
   632         or: self,
   653         orThunk: self,
   633         orThunk: self,
   654         map: map,
   634         map: function (f) {
   655         ap: function (optfab) {
   635           return some(f(a));
   656           return optfab.fold(none, function (fab) {
       
   657             return some(fab(a));
       
   658           });
       
   659         },
   636         },
   660         each: function (f) {
   637         each: function (f) {
   661           f(a);
   638           f(a);
   662         },
   639         },
   663         bind: bind,
   640         bind: bind,
   664         flatten: constant_a,
       
   665         exists: bind,
   641         exists: bind,
   666         forall: bind,
   642         forall: bind,
   667         filter: function (f) {
   643         filter: function (f) {
   668           return f(a) ? me : NONE;
   644           return f(a) ? me : NONE;
   669         },
       
   670         equals: function (o) {
       
   671           return o.is(a);
       
   672         },
       
   673         equals_: function (o, elementEq) {
       
   674           return o.fold(never$1, function (b) {
       
   675             return elementEq(a, b);
       
   676           });
       
   677         },
   645         },
   678         toArray: function () {
   646         toArray: function () {
   679           return [a];
   647           return [a];
   680         },
   648         },
   681         toString: function () {
   649         toString: function () {
   682           return 'some(' + a + ')';
   650           return 'some(' + a + ')';
       
   651         },
       
   652         equals: function (o) {
       
   653           return o.is(a);
       
   654         },
       
   655         equals_: function (o, elementEq) {
       
   656           return o.fold(never, function (b) {
       
   657             return elementEq(a, b);
       
   658           });
   683         }
   659         }
   684       };
   660       };
   685       return me;
   661       return me;
   686     };
   662     };
   687     var from = function (value) {
   663     var from = function (value) {
   692       none: none,
   668       none: none,
   693       from: from
   669       from: from
   694     };
   670     };
   695 
   671 
   696     var typeOf = function (x) {
   672     var typeOf = function (x) {
   697       if (x === null)
   673       if (x === null) {
   698         return 'null';
   674         return 'null';
       
   675       }
   699       var t = typeof x;
   676       var t = typeof x;
   700       if (t === 'object' && Array.prototype.isPrototypeOf(x))
   677       if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
   701         return 'array';
   678         return 'array';
   702       if (t === 'object' && String.prototype.isPrototypeOf(x))
   679       }
       
   680       if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
   703         return 'string';
   681         return 'string';
       
   682       }
   704       return t;
   683       return t;
   705     };
   684     };
   706     var isType$1 = function (type) {
   685     var isType$1 = function (type) {
   707       return function (value) {
   686       return function (value) {
   708         return typeOf(value) === type;
   687         return typeOf(value) === type;
   709       };
   688       };
   710     };
   689     };
       
   690     var isArray$1 = isType$1('array');
   711     var isFunction$1 = isType$1('function');
   691     var isFunction$1 = isType$1('function');
   712     var isNumber$1 = isType$1('number');
   692     var isNumber$1 = isType$1('number');
   713 
   693 
   714     var rawIndexOf = function () {
   694     var nativeSlice = Array.prototype.slice;
   715       var pIndexOf = Array.prototype.indexOf;
   695     var nativeIndexOf = Array.prototype.indexOf;
   716       var fastIndex = function (xs, x) {
   696     var nativePush = Array.prototype.push;
   717         return pIndexOf.call(xs, x);
   697     var rawIndexOf = function (ts, t) {
   718       };
   698       return nativeIndexOf.call(ts, t);
   719       var slowIndex = function (xs, x) {
   699     };
   720         return slowIndexOf(xs, x);
       
   721       };
       
   722       return pIndexOf === undefined ? slowIndex : fastIndex;
       
   723     }();
       
   724     var indexOf = function (xs, x) {
   700     var indexOf = function (xs, x) {
   725       var r = rawIndexOf(xs, x);
   701       var r = rawIndexOf(xs, x);
   726       return r === -1 ? Option.none() : Option.some(r);
   702       return r === -1 ? Option.none() : Option.some(r);
   727     };
   703     };
   728     var exists = function (xs, pred) {
   704     var exists = function (xs, pred) {
   729       return findIndex(xs, pred).isSome();
   705       for (var i = 0, len = xs.length; i < len; i++) {
       
   706         var x = xs[i];
       
   707         if (pred(x, i)) {
       
   708           return true;
       
   709         }
       
   710       }
       
   711       return false;
   730     };
   712     };
   731     var map = function (xs, f) {
   713     var map = function (xs, f) {
   732       var len = xs.length;
   714       var len = xs.length;
   733       var r = new Array(len);
   715       var r = new Array(len);
   734       for (var i = 0; i < len; i++) {
   716       for (var i = 0; i < len; i++) {
   735         var x = xs[i];
   717         var x = xs[i];
   736         r[i] = f(x, i, xs);
   718         r[i] = f(x, i);
   737       }
   719       }
   738       return r;
   720       return r;
   739     };
   721     };
   740     var each = function (xs, f) {
   722     var each = function (xs, f) {
   741       for (var i = 0, len = xs.length; i < len; i++) {
   723       for (var i = 0, len = xs.length; i < len; i++) {
   742         var x = xs[i];
   724         var x = xs[i];
   743         f(x, i, xs);
   725         f(x, i);
   744       }
   726       }
   745     };
   727     };
   746     var filter = function (xs, pred) {
   728     var filter = function (xs, pred) {
   747       var r = [];
   729       var r = [];
   748       for (var i = 0, len = xs.length; i < len; i++) {
   730       for (var i = 0, len = xs.length; i < len; i++) {
   749         var x = xs[i];
   731         var x = xs[i];
   750         if (pred(x, i, xs)) {
   732         if (pred(x, i)) {
   751           r.push(x);
   733           r.push(x);
   752         }
   734         }
   753       }
   735       }
   754       return r;
   736       return r;
   755     };
   737     };
   760       return acc;
   742       return acc;
   761     };
   743     };
   762     var find = function (xs, pred) {
   744     var find = function (xs, pred) {
   763       for (var i = 0, len = xs.length; i < len; i++) {
   745       for (var i = 0, len = xs.length; i < len; i++) {
   764         var x = xs[i];
   746         var x = xs[i];
   765         if (pred(x, i, xs)) {
   747         if (pred(x, i)) {
   766           return Option.some(x);
   748           return Option.some(x);
   767         }
   749         }
   768       }
   750       }
   769       return Option.none();
   751       return Option.none();
   770     };
   752     };
   771     var findIndex = function (xs, pred) {
       
   772       for (var i = 0, len = xs.length; i < len; i++) {
       
   773         var x = xs[i];
       
   774         if (pred(x, i, xs)) {
       
   775           return Option.some(i);
       
   776         }
       
   777       }
       
   778       return Option.none();
       
   779     };
       
   780     var slowIndexOf = function (xs, x) {
       
   781       for (var i = 0, len = xs.length; i < len; ++i) {
       
   782         if (xs[i] === x) {
       
   783           return i;
       
   784         }
       
   785       }
       
   786       return -1;
       
   787     };
       
   788     var push = Array.prototype.push;
       
   789     var flatten$1 = function (xs) {
   753     var flatten$1 = function (xs) {
   790       var r = [];
   754       var r = [];
   791       for (var i = 0, len = xs.length; i < len; ++i) {
   755       for (var i = 0, len = xs.length; i < len; ++i) {
   792         if (!Array.prototype.isPrototypeOf(xs[i]))
   756         if (!isArray$1(xs[i])) {
   793           throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
   757           throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
   794         push.apply(r, xs[i]);
   758         }
       
   759         nativePush.apply(r, xs[i]);
   795       }
   760       }
   796       return r;
   761       return r;
   797     };
   762     };
   798     var slice = Array.prototype.slice;
       
   799     var from$1 = isFunction$1(Array.from) ? Array.from : function (x) {
   763     var from$1 = isFunction$1(Array.from) ? Array.from : function (x) {
   800       return slice.call(x);
   764       return nativeSlice.call(x);
   801     };
   765     };
   802 
   766 
   803     var count = 0;
   767     var count = 0;
   804     var funcs = {
   768     var funcs = {
   805       id: function () {
   769       id: function () {
  1227         return new Collection(matches);
  1191         return new Collection(matches);
  1228       }
  1192       }
  1229     });
  1193     });
  1230 
  1194 
  1231     var Collection$1, proto;
  1195     var Collection$1, proto;
  1232     var push$1 = Array.prototype.push, slice$1 = Array.prototype.slice;
  1196     var push = Array.prototype.push, slice = Array.prototype.slice;
  1233     proto = {
  1197     proto = {
  1234       length: 0,
  1198       length: 0,
  1235       init: function (items) {
  1199       init: function (items) {
  1236         if (items) {
  1200         if (items) {
  1237           this.add(items);
  1201           this.add(items);
  1241         var self = this;
  1205         var self = this;
  1242         if (!global$4.isArray(items)) {
  1206         if (!global$4.isArray(items)) {
  1243           if (items instanceof Collection$1) {
  1207           if (items instanceof Collection$1) {
  1244             self.add(items.toArray());
  1208             self.add(items.toArray());
  1245           } else {
  1209           } else {
  1246             push$1.call(self, items);
  1210             push.call(self, items);
  1247           }
  1211           }
  1248         } else {
  1212         } else {
  1249           push$1.apply(self, items);
  1213           push.apply(self, items);
  1250         }
  1214         }
  1251         return self;
  1215         return self;
  1252       },
  1216       },
  1253       set: function (items) {
  1217       set: function (items) {
  1254         var self = this;
  1218         var self = this;
  1281           }
  1245           }
  1282         }
  1246         }
  1283         return new Collection$1(matches);
  1247         return new Collection$1(matches);
  1284       },
  1248       },
  1285       slice: function () {
  1249       slice: function () {
  1286         return new Collection$1(slice$1.apply(this, arguments));
  1250         return new Collection$1(slice.apply(this, arguments));
  1287       },
  1251       },
  1288       eq: function (index) {
  1252       eq: function (index) {
  1289         return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
  1253         return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
  1290       },
  1254       },
  1291       each: function (callback) {
  1255       each: function (callback) {
  4226         renderUI: renderUI,
  4190         renderUI: renderUI,
  4227         getNotificationManagerImpl: function () {
  4191         getNotificationManagerImpl: function () {
  4228           return NotificationManagerImpl(editor);
  4192           return NotificationManagerImpl(editor);
  4229         },
  4193         },
  4230         getWindowManagerImpl: function () {
  4194         getWindowManagerImpl: function () {
  4231           return WindowManagerImpl(editor);
  4195           return WindowManagerImpl();
  4232         }
  4196         }
  4233       };
  4197       };
  4234     };
  4198     };
  4235     var ThemeApi = { get: get };
  4199     var ThemeApi = { get: get };
  4236 
  4200 
  4237     var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
  4201     var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
  4238 
  4202 
  4239     var path = function (parts, scope) {
  4203     var path = function (parts, scope) {
  4240       var o = scope !== undefined && scope !== null ? scope : Global;
  4204       var o = scope !== undefined && scope !== null ? scope : Global;
  4241       for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i)
  4205       for (var i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
  4242         o = o[parts[i]];
  4206         o = o[parts[i]];
       
  4207       }
  4243       return o;
  4208       return o;
  4244     };
  4209     };
  4245     var resolve = function (p, scope) {
  4210     var resolve = function (p, scope) {
  4246       var parts = p.split('.');
  4211       var parts = p.split('.');
  4247       return path(parts, scope);
  4212       return path(parts, scope);
  4250     var unsafe = function (name, scope) {
  4215     var unsafe = function (name, scope) {
  4251       return resolve(name, scope);
  4216       return resolve(name, scope);
  4252     };
  4217     };
  4253     var getOrDie = function (name, scope) {
  4218     var getOrDie = function (name, scope) {
  4254       var actual = unsafe(name, scope);
  4219       var actual = unsafe(name, scope);
  4255       if (actual === undefined || actual === null)
  4220       if (actual === undefined || actual === null) {
  4256         throw name + ' not available on this browser';
  4221         throw new Error(name + ' not available on this browser');
       
  4222       }
  4257       return actual;
  4223       return actual;
  4258     };
  4224     };
  4259     var Global$1 = { getOrDie: getOrDie };
  4225     var Global$1 = { getOrDie: getOrDie };
  4260 
  4226 
  4261     function FileReader () {
  4227     function FileReader () {
  5171           }
  5137           }
  5172         });
  5138         });
  5173         global$7(input).on('click', function (e) {
  5139         global$7(input).on('click', function (e) {
  5174           e.stopPropagation();
  5140           e.stopPropagation();
  5175         });
  5141         });
  5176         global$7(self.getEl('button')).on('click', function (e) {
  5142         global$7(self.getEl('button')).on('click touchstart', function (e) {
  5177           e.stopPropagation();
  5143           e.stopPropagation();
  5178           input.click();
  5144           input.click();
       
  5145           e.preventDefault();
  5179         });
  5146         });
  5180         self.getEl().appendChild(input);
  5147         self.getEl().appendChild(input);
  5181       },
  5148       },
  5182       remove: function () {
  5149       remove: function () {
  5183         global$7(this.getEl('button')).off();
  5150         global$7(this.getEl('button')).off();
  6313     };
  6280     };
  6314 
  6281 
  6315     var firstMatch = function (regexes, s) {
  6282     var firstMatch = function (regexes, s) {
  6316       for (var i = 0; i < regexes.length; i++) {
  6283       for (var i = 0; i < regexes.length; i++) {
  6317         var x = regexes[i];
  6284         var x = regexes[i];
  6318         if (x.test(s))
  6285         if (x.test(s)) {
  6319           return x;
  6286           return x;
       
  6287         }
  6320       }
  6288       }
  6321       return undefined;
  6289       return undefined;
  6322     };
  6290     };
  6323     var find$1 = function (regexes, agent) {
  6291     var find$1 = function (regexes, agent) {
  6324       var r = firstMatch(regexes, agent);
  6292       var r = firstMatch(regexes, agent);
  6325       if (!r)
  6293       if (!r) {
  6326         return {
  6294         return {
  6327           major: 0,
  6295           major: 0,
  6328           minor: 0
  6296           minor: 0
  6329         };
  6297         };
       
  6298       }
  6330       var group = function (i) {
  6299       var group = function (i) {
  6331         return Number(agent.replace(r, '$' + i));
  6300         return Number(agent.replace(r, '$' + i));
  6332       };
  6301       };
  6333       return nu(group(1), group(2));
  6302       return nu(group(1), group(2));
  6334     };
  6303     };
  6335     var detect = function (versionRegexes, agent) {
  6304     var detect = function (versionRegexes, agent) {
  6336       var cleanedAgent = String(agent).toLowerCase();
  6305       var cleanedAgent = String(agent).toLowerCase();
  6337       if (versionRegexes.length === 0)
  6306       if (versionRegexes.length === 0) {
  6338         return unknown();
  6307         return unknown();
       
  6308       }
  6339       return find$1(versionRegexes, cleanedAgent);
  6309       return find$1(versionRegexes, cleanedAgent);
  6340     };
  6310     };
  6341     var unknown = function () {
  6311     var unknown = function () {
  6342       return nu(0, 0);
  6312       return nu(0, 0);
  6343     };
  6313     };
  6503     var browsers = [
  6473     var browsers = [
  6504       {
  6474       {
  6505         name: 'Edge',
  6475         name: 'Edge',
  6506         versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
  6476         versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
  6507         search: function (uastring) {
  6477         search: function (uastring) {
  6508           var monstrosity = contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
  6478           return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
  6509           return monstrosity;
       
  6510         }
  6479         }
  6511       },
  6480       },
  6512       {
  6481       {
  6513         name: 'Chrome',
  6482         name: 'Chrome',
  6514         versionRegexes: [
  6483         versionRegexes: [
  7828     };
  7797     };
  7829     var isSeparator = function (menuItem) {
  7798     var isSeparator = function (menuItem) {
  7830       return menuItem && menuItem.text === '-';
  7799       return menuItem && menuItem.text === '-';
  7831     };
  7800     };
  7832     var trimMenuItems = function (menuItems) {
  7801     var trimMenuItems = function (menuItems) {
  7833       var menuItems2 = filter(menuItems, function (menuItem, i, menuItems) {
  7802       var menuItems2 = filter(menuItems, function (menuItem, i) {
  7834         return !isSeparator(menuItem) || !isSeparator(menuItems[i - 1]);
  7803         return !isSeparator(menuItem) || !isSeparator(menuItems[i - 1]);
  7835       });
  7804       });
  7836       return filter(menuItems2, function (menuItem, i, menuItems) {
  7805       return filter(menuItems2, function (menuItem, i) {
  7837         return !isSeparator(menuItem) || i > 0 && i < menuItems.length - 1;
  7806         return !isSeparator(menuItem) || i > 0 && i < menuItems2.length - 1;
  7838       });
  7807       });
  7839     };
  7808     };
  7840     var createContextMenuItems = function (editor, context) {
  7809     var createContextMenuItems = function (editor, context) {
  7841       var outputMenuItems = [{ text: '-' }];
  7810       var outputMenuItems = [{ text: '-' }];
  7842       var menuItems = global$4.grep(editor.menuItems, function (menuItem) {
  7811       var menuItems = global$4.grep(editor.menuItems, function (menuItem) {