Subversion Repositories oidplus

Rev

Rev 637 | Rev 759 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 637 Rev 679
Line 2... Line 2...
2
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
2
 * Copyright (c) Tiny Technologies, Inc. All rights reserved.
3
 * Licensed under the LGPL or a commercial license.
3
 * Licensed under the LGPL or a commercial license.
4
 * For LGPL see License.txt in the project root for license information.
4
 * For LGPL see License.txt in the project root for license information.
5
 * For commercial licenses see https://www.tiny.cloud/
5
 * For commercial licenses see https://www.tiny.cloud/
6
 *
6
 *
7
 * Version: 5.9.2 (2021-09-08)
7
 * Version: 5.10.2 (2021-11-17)
8
 */
8
 */
9
(function () {
9
(function () {
10
    'use strict';
10
    'use strict';
11
 
11
 
12
    var Cell = function (initial) {
12
    var Cell = function (initial) {
Line 21... Line 21...
21
        get: get,
21
        get: get,
22
        set: set
22
        set: set
23
      };
23
      };
24
    };
24
    };
25
 
25
 
26
    var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
26
    var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager');
27
 
27
 
28
    var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
28
    var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
29
 
29
 
30
    var typeOf = function (x) {
30
    var typeOf = function (x) {
31
      var t = typeof x;
31
      var t = typeof x;
32
      if (x === null) {
32
      if (x === null) {
33
        return 'null';
33
        return 'null';
Line 158... Line 158...
158
      some: some,
158
      some: some,
159
      none: none,
159
      none: none,
160
      from: from
160
      from: from
161
    };
161
    };
162
 
162
 
163
    var create$1 = function (width, height) {
163
    var exports$1 = {}, module = { exports: exports$1 };
164
      return resize(document.createElement('canvas'), width, height);
164
    (function (define, exports, module, require) {
165
    };
-
 
166
    var clone = function (canvas) {
165
      (function (global, factory) {
167
      var tCanvas = create$1(canvas.width, canvas.height);
166
        typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EphoxContactWrapper = factory());
168
      var ctx = get2dContext(tCanvas);
-
 
169
      ctx.drawImage(canvas, 0, 0);
-
 
170
      return tCanvas;
167
      }(this, function () {
171
    };
-
 
172
    var get2dContext = function (canvas) {
168
        var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
173
      return canvas.getContext('2d');
169
        var promise = { exports: {} };
174
    };
-
 
175
    var resize = function (canvas, width, height) {
170
        (function (module) {
176
      canvas.width = width;
171
          (function (root) {
177
      canvas.height = height;
172
            var setTimeoutFunc = setTimeout;
178
      return canvas;
173
            function noop() {
179
    };
174
            }
180
 
-
 
181
    var getWidth = function (image) {
175
            function bind(fn, thisArg) {
182
      return image.naturalWidth || image.width;
-
 
183
    };
-
 
184
    var getHeight = function (image) {
176
              return function () {
185
      return image.naturalHeight || image.height;
177
                fn.apply(thisArg, arguments);
186
    };
178
              };
187
 
-
 
188
    var promise = function () {
-
 
189
      var Promise = function (fn) {
-
 
190
        if (typeof this !== 'object') {
-
 
191
          throw new TypeError('Promises must be constructed via new');
-
 
192
        }
179
            }
-
 
180
            function Promise(fn) {
-
 
181
              if (typeof this !== 'object')
-
 
182
                throw new TypeError('Promises must be constructed via new');
193
        if (typeof fn !== 'function') {
183
              if (typeof fn !== 'function')
194
          throw new TypeError('not a function');
184
                throw new TypeError('not a function');
195
        }
185
              this._state = 0;
196
        this._state = null;
186
              this._handled = false;
197
        this._value = null;
187
              this._value = undefined;
198
        this._deferreds = [];
188
              this._deferreds = [];
199
        doResolve(fn, bind(resolve, this), bind(reject, this));
-
 
200
      };
-
 
201
      var anyWindow = window;
-
 
202
      var asap = Promise.immediateFn || typeof anyWindow.setImmediate === 'function' && anyWindow.setImmediate || function (fn) {
-
 
203
        return setTimeout(fn, 1);
-
 
204
      };
-
 
205
      var bind = function (fn, thisArg) {
189
              doResolve(fn, this);
206
        return function () {
-
 
207
          var args = [];
-
 
208
          for (var _i = 0; _i < arguments.length; _i++) {
-
 
209
            args[_i] = arguments[_i];
-
 
210
          }
190
            }
211
          return fn.apply(thisArg, args);
191
            function handle(self, deferred) {
212
        };
-
 
213
      };
-
 
214
      var isArray = Array.isArray || function (value) {
192
              while (self._state === 3) {
215
        return Object.prototype.toString.call(value) === '[object Array]';
-
 
216
      };
-
 
217
      function handle(deferred) {
193
                self = self._value;
218
        var me = this;
194
              }
219
        if (this._state === null) {
195
              if (self._state === 0) {
220
          this._deferreds.push(deferred);
196
                self._deferreds.push(deferred);
221
          return;
197
                return;
222
        }
198
              }
-
 
199
              self._handled = true;
223
        asap(function () {
200
              Promise._immediateFn(function () {
224
          var cb = me._state ? deferred.onFulfilled : deferred.onRejected;
201
                var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
225
          if (cb === null) {
202
                if (cb === null) {
226
            (me._state ? deferred.resolve : deferred.reject)(me._value);
203
                  (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
227
            return;
204
                  return;
228
          }
205
                }
229
          var ret;
206
                var ret;
230
          try {
207
                try {
231
            ret = cb(me._value);
208
                  ret = cb(self._value);
232
          } catch (e) {
209
                } catch (e) {
233
            deferred.reject(e);
210
                  reject(deferred.promise, e);
234
            return;
211
                  return;
235
          }
212
                }
236
          deferred.resolve(ret);
213
                resolve(deferred.promise, ret);
237
        });
214
              });
238
      }
215
            }
239
      function resolve(newValue) {
216
            function resolve(self, newValue) {
240
        try {
217
              try {
241
          if (newValue === this) {
218
                if (newValue === self)
242
            throw new TypeError('A promise cannot be resolved with itself.');
219
                  throw new TypeError('A promise cannot be resolved with itself.');
243
          }
-
 
244
          if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
220
                if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
245
            var then = newValue.then;
221
                  var then = newValue.then;
-
 
222
                  if (newValue instanceof Promise) {
-
 
223
                    self._state = 3;
-
 
224
                    self._value = newValue;
-
 
225
                    finale(self);
-
 
226
                    return;
246
            if (typeof then === 'function') {
227
                  } else if (typeof then === 'function') {
247
              doResolve(bind(then, newValue), bind(resolve, this), bind(reject, this));
228
                    doResolve(bind(then, newValue), self);
248
              return;
229
                    return;
249
            }
230
                  }
250
          }
231
                }
251
          this._state = true;
232
                self._state = 1;
252
          this._value = newValue;
233
                self._value = newValue;
253
          finale.call(this);
234
                finale(self);
254
        } catch (e) {
235
              } catch (e) {
255
          reject.call(this, e);
236
                reject(self, e);
256
        }
237
              }
257
      }
238
            }
258
      function reject(newValue) {
239
            function reject(self, newValue) {
259
        this._state = false;
240
              self._state = 2;
260
        this._value = newValue;
241
              self._value = newValue;
261
        finale.call(this);
242
              finale(self);
262
      }
-
 
263
      function finale() {
-
 
264
        for (var _i = 0, _a = this._deferreds; _i < _a.length; _i++) {
-
 
265
          var deferred = _a[_i];
-
 
266
          handle.call(this, deferred);
-
 
267
        }
243
            }
-
 
244
            function finale(self) {
-
 
245
              if (self._state === 2 && self._deferreds.length === 0) {
-
 
246
                Promise._immediateFn(function () {
-
 
247
                  if (!self._handled) {
-
 
248
                    Promise._unhandledRejectionFn(self._value);
-
 
249
                  }
-
 
250
                });
-
 
251
              }
-
 
252
              for (var i = 0, len = self._deferreds.length; i < len; i++) {
268
        this._deferreds = [];
253
                handle(self, self._deferreds[i]);
269
      }
254
              }
-
 
255
              self._deferreds = null;
-
 
256
            }
270
      function Handler(onFulfilled, onRejected, resolve, reject) {
257
            function Handler(onFulfilled, onRejected, promise) {
271
        this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
258
              this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
272
        this.onRejected = typeof onRejected === 'function' ? onRejected : null;
259
              this.onRejected = typeof onRejected === 'function' ? onRejected : null;
273
        this.resolve = resolve;
260
              this.promise = promise;
274
        this.reject = reject;
-
 
275
      }
261
            }
276
      var doResolve = function (fn, onFulfilled, onRejected) {
262
            function doResolve(fn, self) {
277
        var done = false;
263
              var done = false;
278
        try {
264
              try {
279
          fn(function (value) {
265
                fn(function (value) {
280
            if (done) {
266
                  if (done)
281
              return;
267
                    return;
282
            }
-
 
283
            done = true;
268
                  done = true;
284
            onFulfilled(value);
269
                  resolve(self, value);
285
          }, function (reason) {
270
                }, function (reason) {
286
            if (done) {
271
                  if (done)
287
              return;
272
                    return;
288
            }
-
 
289
            done = true;
273
                  done = true;
290
            onRejected(reason);
274
                  reject(self, reason);
291
          });
275
                });
292
        } catch (ex) {
276
              } catch (ex) {
293
          if (done) {
277
                if (done)
294
            return;
278
                  return;
295
          }
-
 
296
          done = true;
279
                done = true;
297
          onRejected(ex);
280
                reject(self, ex);
298
        }
281
              }
299
      };
282
            }
300
      Promise.prototype.catch = function (onRejected) {
283
            Promise.prototype['catch'] = function (onRejected) {
301
        return this.then(null, onRejected);
284
              return this.then(null, onRejected);
302
      };
285
            };
303
      Promise.prototype.then = function (onFulfilled, onRejected) {
286
            Promise.prototype.then = function (onFulfilled, onRejected) {
304
        var me = this;
-
 
305
        return new Promise(function (resolve, reject) {
287
              var prom = new this.constructor(noop);
306
          handle.call(me, new Handler(onFulfilled, onRejected, resolve, reject));
288
              handle(this, new Handler(onFulfilled, onRejected, prom));
307
        });
289
              return prom;
308
      };
290
            };
309
      Promise.all = function () {
291
            Promise.all = function (arr) {
310
        var values = [];
-
 
311
        for (var _i = 0; _i < arguments.length; _i++) {
292
              var args = Array.prototype.slice.call(arr);
312
          values[_i] = arguments[_i];
-
 
313
        }
-
 
314
        var args = Array.prototype.slice.call(values.length === 1 && isArray(values[0]) ? values[0] : values);
-
 
315
        return new Promise(function (resolve, reject) {
293
              return new Promise(function (resolve, reject) {
316
          if (args.length === 0) {
294
                if (args.length === 0)
317
            return resolve([]);
295
                  return resolve([]);
318
          }
-
 
319
          var remaining = args.length;
296
                var remaining = args.length;
320
          var res = function (i, val) {
297
                function res(i, val) {
321
            try {
298
                  try {
322
              if (val && (typeof val === 'object' || typeof val === 'function')) {
299
                    if (val && (typeof val === 'object' || typeof val === 'function')) {
323
                var then = val.then;
300
                      var then = val.then;
324
                if (typeof then === 'function') {
301
                      if (typeof then === 'function') {
325
                  then.call(val, function (val) {
302
                        then.call(val, function (val) {
Line 333... Line 310...
333
                resolve(args);
310
                      resolve(args);
334
              }
311
                    }
335
            } catch (ex) {
312
                  } catch (ex) {
336
              reject(ex);
313
                    reject(ex);
337
            }
314
                  }
338
          };
315
                }
339
          for (var i = 0; i < args.length; i++) {
316
                for (var i = 0; i < args.length; i++) {
340
            res(i, args[i]);
317
                  res(i, args[i]);
341
          }
318
                }
342
        });
319
              });
343
      };
320
            };
Line 347... Line 324...
347
        }
324
              }
348
        return new Promise(function (resolve) {
325
              return new Promise(function (resolve) {
349
          resolve(value);
326
                resolve(value);
350
        });
327
              });
351
      };
328
            };
352
      Promise.reject = function (reason) {
329
            Promise.reject = function (value) {
353
        return new Promise(function (resolve, reject) {
330
              return new Promise(function (resolve, reject) {
354
          reject(reason);
331
                reject(value);
355
        });
332
              });
356
      };
333
            };
357
      Promise.race = function (values) {
334
            Promise.race = function (values) {
358
        return new Promise(function (resolve, reject) {
335
              return new Promise(function (resolve, reject) {
359
          for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
336
                for (var i = 0, len = values.length; i < len; i++) {
360
            var value = values_1[_i];
-
 
361
            value.then(resolve, reject);
337
                  values[i].then(resolve, reject);
362
          }
338
                }
363
        });
339
              });
364
      };
340
            };
-
 
341
            Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
-
 
342
              setImmediate(fn);
-
 
343
            } : function (fn) {
-
 
344
              setTimeoutFunc(fn, 0);
-
 
345
            };
-
 
346
            Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
-
 
347
              if (typeof console !== 'undefined' && console) {
-
 
348
                console.warn('Possible Unhandled Promise Rejection:', err);
-
 
349
              }
-
 
350
            };
-
 
351
            Promise._setImmediateFn = function _setImmediateFn(fn) {
-
 
352
              Promise._immediateFn = fn;
-
 
353
            };
-
 
354
            Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
-
 
355
              Promise._unhandledRejectionFn = fn;
-
 
356
            };
-
 
357
            if (module.exports) {
-
 
358
              module.exports = Promise;
-
 
359
            } else if (!root.Promise) {
-
 
360
              root.Promise = Promise;
-
 
361
            }
-
 
362
          }(commonjsGlobal));
-
 
363
        }(promise));
-
 
364
        var promisePolyfill = promise.exports;
-
 
365
        var Global = function () {
-
 
366
          if (typeof window !== 'undefined') {
-
 
367
            return window;
-
 
368
          } else {
-
 
369
            return Function('return this;')();
-
 
370
          }
-
 
371
        }();
-
 
372
        var promisePolyfill_1 = { boltExport: Global.Promise || promisePolyfill };
-
 
373
        return promisePolyfill_1;
-
 
374
      }));
-
 
375
    }(undefined, exports$1, module));
-
 
376
    var Promise$1 = module.exports.boltExport;
-
 
377
 
-
 
378
    var create$1 = function (width, height) {
-
 
379
      return resize(document.createElement('canvas'), width, height);
-
 
380
    };
-
 
381
    var clone = function (canvas) {
-
 
382
      var tCanvas = create$1(canvas.width, canvas.height);
-
 
383
      var ctx = get2dContext(tCanvas);
-
 
384
      ctx.drawImage(canvas, 0, 0);
-
 
385
      return tCanvas;
-
 
386
    };
-
 
387
    var get2dContext = function (canvas) {
-
 
388
      return canvas.getContext('2d');
-
 
389
    };
-
 
390
    var resize = function (canvas, width, height) {
-
 
391
      canvas.width = width;
-
 
392
      canvas.height = height;
365
      return Promise;
393
      return canvas;
-
 
394
    };
-
 
395
 
-
 
396
    var getWidth = function (image) {
-
 
397
      return image.naturalWidth || image.width;
-
 
398
    };
-
 
399
    var getHeight = function (image) {
-
 
400
      return image.naturalHeight || image.height;
366
    };
401
    };
367
    var Promise$1 = window.Promise ? window.Promise : promise();
-
 
368
 
402
 
369
    var imageToBlob$2 = function (image) {
403
    var imageToBlob$2 = function (image) {
370
      var src = image.src;
404
      var src = image.src;
371
      if (src.indexOf('data:') === 0) {
405
      if (src.indexOf('data:') === 0) {
372
        return dataUriToBlob(src);
406
        return dataUriToBlob(src);
Line 1002... Line 1036...
1002
      return child$1(scope, function (e) {
1036
      return child$1(scope, function (e) {
1003
        return is(e, selector);
1037
        return is(e, selector);
1004
      });
1038
      });
1005
    };
1039
    };
1006
 
1040
 
1007
    var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
1041
    var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay');
1008
 
1042
 
1009
    var global$1 = tinymce.util.Tools.resolve('tinymce.util.Promise');
1043
    var global$2 = tinymce.util.Tools.resolve('tinymce.util.Promise');
1010
 
1044
 
1011
    var global = tinymce.util.Tools.resolve('tinymce.util.URI');
1045
    var global$1 = tinymce.util.Tools.resolve('tinymce.util.URI');
1012
 
1046
 
1013
    var getToolbarItems = function (editor) {
1047
    var getToolbarItems = function (editor) {
1014
      return editor.getParam('imagetools_toolbar', 'rotateleft rotateright flipv fliph editimage imageoptions');
1048
      return editor.getParam('imagetools_toolbar', 'rotateleft rotateright flipv fliph editimage imageoptions');
1015
    };
1049
    };
1016
    var getProxyUrl = function (editor) {
1050
    var getProxyUrl = function (editor) {
Line 1132... Line 1166...
1132
    var createId = function () {
1166
    var createId = function () {
1133
      return 'imagetools' + count++;
1167
      return 'imagetools' + count++;
1134
    };
1168
    };
1135
    var isLocalImage = function (editor, img) {
1169
    var isLocalImage = function (editor, img) {
1136
      var url = img.src;
1170
      var url = img.src;
1137
      return url.indexOf('data:') === 0 || url.indexOf('blob:') === 0 || new global(url).host === editor.documentBaseURI.host;
1171
      return url.indexOf('data:') === 0 || url.indexOf('blob:') === 0 || new global$1(url).host === editor.documentBaseURI.host;
1138
    };
1172
    };
1139
    var isCorsImage = function (editor, img) {
1173
    var isCorsImage = function (editor, img) {
1140
      return global$3.inArray(getCorsHosts(editor), new global(img.src).host) !== -1;
1174
      return global$4.inArray(getCorsHosts(editor), new global$1(img.src).host) !== -1;
1141
    };
1175
    };
1142
    var isCorsWithCredentialsImage = function (editor, img) {
1176
    var isCorsWithCredentialsImage = function (editor, img) {
1143
      return global$3.inArray(getCredentialsHosts(editor), new global(img.src).host) !== -1;
1177
      return global$4.inArray(getCredentialsHosts(editor), new global$1(img.src).host) !== -1;
1144
    };
1178
    };
1145
    var defaultFetchImage = function (editor, img) {
1179
    var defaultFetchImage = function (editor, img) {
1146
      if (isCorsImage(editor, img)) {
1180
      if (isCorsImage(editor, img)) {
1147
        return getUrl(img.src, null, isCorsWithCredentialsImage(editor, img));
1181
        return getUrl(img.src, null, isCorsWithCredentialsImage(editor, img));
1148
      }
1182
      }
Line 1162... Line 1196...
1162
      });
1196
      });
1163
    };
1197
    };
1164
    var findBlob = function (editor, img) {
1198
    var findBlob = function (editor, img) {
1165
      var blobInfo = editor.editorUpload.blobCache.getByUri(img.src);
1199
      var blobInfo = editor.editorUpload.blobCache.getByUri(img.src);
1166
      if (blobInfo) {
1200
      if (blobInfo) {
1167
        return global$1.resolve(blobInfo.blob());
1201
        return global$2.resolve(blobInfo.blob());
1168
      }
1202
      }
1169
      return imageToBlob(editor, img);
1203
      return imageToBlob(editor, img);
1170
    };
1204
    };
1171
    var startTimedUpload = function (editor, imageUploadTimerState) {
1205
    var startTimedUpload = function (editor, imageUploadTimerState) {
1172
      var imageUploadTimer = global$2.setEditorTimeout(editor, function () {
1206
      var imageUploadTimer = global$3.setEditorTimeout(editor, function () {
1173
        editor.editorUpload.uploadImagesAuto();
1207
        editor.editorUpload.uploadImagesAuto();
1174
      }, getUploadTimeout(editor));
1208
      }, getUploadTimeout(editor));
1175
      imageUploadTimerState.set(imageUploadTimer);
1209
      imageUploadTimerState.set(imageUploadTimer);
1176
    };
1210
    };
1177
    var cancelTimedUpload = function (imageUploadTimerState) {
1211
    var cancelTimedUpload = function (imageUploadTimerState) {
1178
      global$2.clearTimeout(imageUploadTimerState.get());
1212
      global$3.clearTimeout(imageUploadTimerState.get());
1179
    };
1213
    };
1180
    var updateSelectedImage = function (editor, origBlob, ir, uploadImmediately, imageUploadTimerState, selectedImage, size) {
1214
    var updateSelectedImage = function (editor, origBlob, ir, uploadImmediately, imageUploadTimerState, selectedImage, size) {
1181
      return ir.toBlob().then(function (blob) {
1215
      return ir.toBlob().then(function (blob) {
1182
        var uri, name, filename, blobInfo;
1216
        var uri, name, filename, blobInfo;
1183
        var blobCache = editor.editorUpload.blobCache;
1217
        var blobCache = editor.editorUpload.blobCache;
Line 1364... Line 1398...
1364
        });
1398
        });
1365
      };
1399
      };
1366
    };
1400
    };
1367
 
1401
 
1368
    var register$2 = function (editor, imageUploadTimerState) {
1402
    var register$2 = function (editor, imageUploadTimerState) {
1369
      global$3.each({
1403
      global$4.each({
1370
        mceImageRotateLeft: rotate(editor, imageUploadTimerState, -90),
1404
        mceImageRotateLeft: rotate(editor, imageUploadTimerState, -90),
1371
        mceImageRotateRight: rotate(editor, imageUploadTimerState, 90),
1405
        mceImageRotateRight: rotate(editor, imageUploadTimerState, 90),
1372
        mceImageFlipVertical: flip(editor, imageUploadTimerState, 'v'),
1406
        mceImageFlipVertical: flip(editor, imageUploadTimerState, 'v'),
1373
        mceImageFlipHorizontal: flip(editor, imageUploadTimerState, 'h'),
1407
        mceImageFlipHorizontal: flip(editor, imageUploadTimerState, 'h'),
1374
        mceEditImage: makeOpen(editor, imageUploadTimerState)
1408
        mceEditImage: makeOpen(editor, imageUploadTimerState)
Line 1480... Line 1514...
1480
        scope: 'node'
1514
        scope: 'node'
1481
      });
1515
      });
1482
    };
1516
    };
1483
 
1517
 
1484
    function Plugin () {
1518
    function Plugin () {
1485
      global$4.add('imagetools', function (editor) {
1519
      global$5.add('imagetools', function (editor) {
1486
        var imageUploadTimerState = Cell(0);
1520
        var imageUploadTimerState = Cell(0);
1487
        var lastSelectedImageState = Cell(null);
1521
        var lastSelectedImageState = Cell(null);
1488
        register$2(editor, imageUploadTimerState);
1522
        register$2(editor, imageUploadTimerState);
1489
        register$1(editor);
1523
        register$1(editor);
1490
        register(editor);
1524
        register(editor);