tinymce-rails 4.9.6 → 4.9.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c68e4ad6f27c5f42e0fb00e73e36d1f4ea4c21ab8ef650227e9bcceeac31eeb7
4
- data.tar.gz: a4c413955e55aba19778d176a23577c78f22ee49156a8c19ac124f97f1ea228b
3
+ metadata.gz: 2d4a9e6b463099f136b4a76925e428f4adbdc905d04d316a97b1ea3508a10ddf
4
+ data.tar.gz: 103162d595c1bd4948ef0f41c101a5388a77d521737855a076c4c077d7b92038
5
5
  SHA512:
6
- metadata.gz: e7a4e4f415e7731cebfbe53f6e47a597475b2e86c5d57517d35245f3e7875b8743187321d3e6388dcd511e7ce67fc33fbdbc78a2fb68856e0fea391ebc897c67
7
- data.tar.gz: 28ffaa2db4e126fa7573621e7def5bc9de119533a1db81460a18d334e74ba2e82fde8ed60f250d4fff64188751950f990e3f43f543af98869c7e6a98847099d3
6
+ metadata.gz: 80ed2f75eb71bab2b14c5d380d6c8c9400079f253baa34471102fd71afa3019a3931f1843375a00f47d0398e43eb672568a2c6960bb6cf06ce62a2f00bbc28c6
7
+ data.tar.gz: cbc4371630d008d8b2d308ad0cd9687b43487bfbdf9e6f1d15f0bff8295ea5c41a03fa213a3d1e488103ae234600cce3660993c411718d4bedf70ac6fe62ac14
@@ -1,4 +1,4 @@
1
- // 4.9.6 (2019-09-02)
1
+ // 4.9.11 (2020-07-13)
2
2
  (function () {
3
3
  (function (domGlobals) {
4
4
  'use strict';
@@ -53,8 +53,6 @@
53
53
  var never = constant(false);
54
54
  var always = constant(true);
55
55
 
56
- var never$1 = never;
57
- var always$1 = always;
58
56
  var none = function () {
59
57
  return NONE;
60
58
  };
@@ -68,37 +66,27 @@
68
66
  var id = function (n) {
69
67
  return n;
70
68
  };
71
- var noop = function () {
72
- };
73
- var nul = function () {
74
- return null;
75
- };
76
- var undef = function () {
77
- return undefined;
78
- };
79
69
  var me = {
80
70
  fold: function (n, s) {
81
71
  return n();
82
72
  },
83
- is: never$1,
84
- isSome: never$1,
85
- isNone: always$1,
73
+ is: never,
74
+ isSome: never,
75
+ isNone: always,
86
76
  getOr: id,
87
77
  getOrThunk: call,
88
78
  getOrDie: function (msg) {
89
79
  throw new Error(msg || 'error: getOrDie called on none.');
90
80
  },
91
- getOrNull: nul,
92
- getOrUndefined: undef,
81
+ getOrNull: constant(null),
82
+ getOrUndefined: constant(undefined),
93
83
  or: id,
94
84
  orThunk: call,
95
85
  map: none,
96
- ap: none,
97
86
  each: noop,
98
87
  bind: none,
99
- flatten: none,
100
- exists: never$1,
101
- forall: always$1,
88
+ exists: never,
89
+ forall: always,
102
90
  filter: none,
103
91
  equals: eq,
104
92
  equals_: eq,
@@ -113,15 +101,10 @@
113
101
  return me;
114
102
  }();
115
103
  var some = function (a) {
116
- var constant_a = function () {
117
- return a;
118
- };
104
+ var constant_a = constant(a);
119
105
  var self = function () {
120
106
  return me;
121
107
  };
122
- var map = function (f) {
123
- return some(f(a));
124
- };
125
108
  var bind = function (f) {
126
109
  return f(a);
127
110
  };
@@ -132,8 +115,8 @@
132
115
  is: function (v) {
133
116
  return a === v;
134
117
  },
135
- isSome: always$1,
136
- isNone: never$1,
118
+ isSome: always,
119
+ isNone: never,
137
120
  getOr: constant_a,
138
121
  getOrThunk: constant_a,
139
122
  getOrDie: constant_a,
@@ -141,35 +124,31 @@
141
124
  getOrUndefined: constant_a,
142
125
  or: self,
143
126
  orThunk: self,
144
- map: map,
145
- ap: function (optfab) {
146
- return optfab.fold(none, function (fab) {
147
- return some(fab(a));
148
- });
127
+ map: function (f) {
128
+ return some(f(a));
149
129
  },
150
130
  each: function (f) {
151
131
  f(a);
152
132
  },
153
133
  bind: bind,
154
- flatten: constant_a,
155
134
  exists: bind,
156
135
  forall: bind,
157
136
  filter: function (f) {
158
137
  return f(a) ? me : NONE;
159
138
  },
139
+ toArray: function () {
140
+ return [a];
141
+ },
142
+ toString: function () {
143
+ return 'some(' + a + ')';
144
+ },
160
145
  equals: function (o) {
161
146
  return o.is(a);
162
147
  },
163
148
  equals_: function (o, elementEq) {
164
- return o.fold(never$1, function (b) {
149
+ return o.fold(never, function (b) {
165
150
  return elementEq(a, b);
166
151
  });
167
- },
168
- toArray: function () {
169
- return [a];
170
- },
171
- toString: function () {
172
- return 'some(' + a + ')';
173
152
  }
174
153
  };
175
154
  return me;
@@ -209,17 +188,12 @@
209
188
  var isFunction = isType('function');
210
189
  var isNumber = isType('number');
211
190
 
212
- var slice = Array.prototype.slice;
213
- var rawIndexOf = function () {
214
- var pIndexOf = Array.prototype.indexOf;
215
- var fastIndex = function (xs, x) {
216
- return pIndexOf.call(xs, x);
217
- };
218
- var slowIndex = function (xs, x) {
219
- return slowIndexOf(xs, x);
220
- };
221
- return pIndexOf === undefined ? slowIndex : fastIndex;
222
- }();
191
+ var nativeSlice = Array.prototype.slice;
192
+ var nativeIndexOf = Array.prototype.indexOf;
193
+ var nativePush = Array.prototype.push;
194
+ var rawIndexOf = function (ts, t) {
195
+ return nativeIndexOf.call(ts, t);
196
+ };
223
197
  var indexOf = function (xs, x) {
224
198
  var r = rawIndexOf(xs, x);
225
199
  return r === -1 ? Option.none() : Option.some(r);
@@ -228,27 +202,33 @@
228
202
  return rawIndexOf(xs, x) > -1;
229
203
  };
230
204
  var exists = function (xs, pred) {
231
- return findIndex(xs, pred).isSome();
205
+ for (var i = 0, len = xs.length; i < len; i++) {
206
+ var x = xs[i];
207
+ if (pred(x, i)) {
208
+ return true;
209
+ }
210
+ }
211
+ return false;
232
212
  };
233
213
  var map = function (xs, f) {
234
214
  var len = xs.length;
235
215
  var r = new Array(len);
236
216
  for (var i = 0; i < len; i++) {
237
217
  var x = xs[i];
238
- r[i] = f(x, i, xs);
218
+ r[i] = f(x, i);
239
219
  }
240
220
  return r;
241
221
  };
242
222
  var each = function (xs, f) {
243
223
  for (var i = 0, len = xs.length; i < len; i++) {
244
224
  var x = xs[i];
245
- f(x, i, xs);
225
+ f(x, i);
246
226
  }
247
227
  };
248
228
  var eachr = function (xs, f) {
249
229
  for (var i = xs.length - 1; i >= 0; i--) {
250
230
  var x = xs[i];
251
- f(x, i, xs);
231
+ f(x, i);
252
232
  }
253
233
  };
254
234
  var partition = function (xs, pred) {
@@ -256,7 +236,7 @@
256
236
  var fail = [];
257
237
  for (var i = 0, len = xs.length; i < len; i++) {
258
238
  var x = xs[i];
259
- var arr = pred(x, i, xs) ? pass : fail;
239
+ var arr = pred(x, i) ? pass : fail;
260
240
  arr.push(x);
261
241
  }
262
242
  return {
@@ -268,7 +248,7 @@
268
248
  var r = [];
269
249
  for (var i = 0, len = xs.length; i < len; i++) {
270
250
  var x = xs[i];
271
- if (pred(x, i, xs)) {
251
+ if (pred(x, i)) {
272
252
  r.push(x);
273
253
  }
274
254
  }
@@ -289,7 +269,7 @@
289
269
  var find = function (xs, pred) {
290
270
  for (var i = 0, len = xs.length; i < len; i++) {
291
271
  var x = xs[i];
292
- if (pred(x, i, xs)) {
272
+ if (pred(x, i)) {
293
273
  return Option.some(x);
294
274
  }
295
275
  }
@@ -298,28 +278,19 @@
298
278
  var findIndex = function (xs, pred) {
299
279
  for (var i = 0, len = xs.length; i < len; i++) {
300
280
  var x = xs[i];
301
- if (pred(x, i, xs)) {
281
+ if (pred(x, i)) {
302
282
  return Option.some(i);
303
283
  }
304
284
  }
305
285
  return Option.none();
306
286
  };
307
- var slowIndexOf = function (xs, x) {
308
- for (var i = 0, len = xs.length; i < len; ++i) {
309
- if (xs[i] === x) {
310
- return i;
311
- }
312
- }
313
- return -1;
314
- };
315
- var push = Array.prototype.push;
316
287
  var flatten = function (xs) {
317
288
  var r = [];
318
289
  for (var i = 0, len = xs.length; i < len; ++i) {
319
290
  if (!isArray(xs[i])) {
320
291
  throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
321
292
  }
322
- push.apply(r, xs[i]);
293
+ nativePush.apply(r, xs[i]);
323
294
  }
324
295
  return r;
325
296
  };
@@ -330,14 +301,14 @@
330
301
  var forall = function (xs, pred) {
331
302
  for (var i = 0, len = xs.length; i < len; ++i) {
332
303
  var x = xs[i];
333
- if (pred(x, i, xs) !== true) {
304
+ if (pred(x, i) !== true) {
334
305
  return false;
335
306
  }
336
307
  }
337
308
  return true;
338
309
  };
339
310
  var reverse = function (xs) {
340
- var r = slice.call(xs, 0);
311
+ var r = nativeSlice.call(xs, 0);
341
312
  r.reverse();
342
313
  return r;
343
314
  };
@@ -355,7 +326,7 @@
355
326
  return r;
356
327
  };
357
328
  var sort = function (xs, comparator) {
358
- var copy = slice.call(xs, 0);
329
+ var copy = nativeSlice.call(xs, 0);
359
330
  copy.sort(comparator);
360
331
  return copy;
361
332
  };
@@ -366,7 +337,7 @@
366
337
  return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]);
367
338
  };
368
339
  var from$1 = isFunction(Array.from) ? Array.from : function (x) {
369
- return slice.call(x);
340
+ return nativeSlice.call(x);
370
341
  };
371
342
 
372
343
  var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
@@ -1094,7 +1065,7 @@
1094
1065
  hasDuplicate = true;
1095
1066
  }
1096
1067
  return 0;
1097
- }, strundefined = typeof undefined, MAX_NEGATIVE = 1 << 31, hasOwn = {}.hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push$1 = arr.push, slice$1 = arr.slice, indexOf$1 = arr.indexOf || function (elem) {
1068
+ }, strundefined = typeof undefined, MAX_NEGATIVE = 1 << 31, hasOwn = {}.hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push = arr.push, slice = arr.slice, indexOf$1 = arr.indexOf || function (elem) {
1098
1069
  var i = 0, len = this.length;
1099
1070
  for (; i < len; i++) {
1100
1071
  if (this[i] === elem) {
@@ -1116,12 +1087,12 @@
1116
1087
  return high !== high || escapedWhitespace ? escaped : high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
1117
1088
  };
1118
1089
  try {
1119
- push$1.apply(arr = slice$1.call(preferredDoc.childNodes), preferredDoc.childNodes);
1090
+ push.apply(arr = slice.call(preferredDoc.childNodes), preferredDoc.childNodes);
1120
1091
  arr[preferredDoc.childNodes.length].nodeType;
1121
1092
  } catch (e) {
1122
- push$1 = {
1093
+ push = {
1123
1094
  apply: arr.length ? function (target, els) {
1124
- push_native.apply(target, slice$1.call(els));
1095
+ push_native.apply(target, slice.call(els));
1125
1096
  } : function (target, els) {
1126
1097
  var j = target.length, i = 0;
1127
1098
  while (target[j++] = els[i++]) {
@@ -1163,10 +1134,10 @@
1163
1134
  }
1164
1135
  }
1165
1136
  } else if (match[2]) {
1166
- push$1.apply(results, context.getElementsByTagName(selector));
1137
+ push.apply(results, context.getElementsByTagName(selector));
1167
1138
  return results;
1168
1139
  } else if ((m = match[3]) && support.getElementsByClassName) {
1169
- push$1.apply(results, context.getElementsByClassName(m));
1140
+ push.apply(results, context.getElementsByClassName(m));
1170
1141
  return results;
1171
1142
  }
1172
1143
  }
@@ -1191,7 +1162,7 @@
1191
1162
  }
1192
1163
  if (newSelector) {
1193
1164
  try {
1194
- push$1.apply(results, newContext.querySelectorAll(newSelector));
1165
+ push.apply(results, newContext.querySelectorAll(newSelector));
1195
1166
  return results;
1196
1167
  } catch (qsaError) {
1197
1168
  } finally {
@@ -1947,7 +1918,7 @@
1947
1918
  if (postFinder) {
1948
1919
  postFinder(null, results, matcherOut, xml);
1949
1920
  } else {
1950
- push$1.apply(results, matcherOut);
1921
+ push.apply(results, matcherOut);
1951
1922
  }
1952
1923
  }
1953
1924
  });
@@ -2023,7 +1994,7 @@
2023
1994
  }
2024
1995
  setMatched = condense(setMatched);
2025
1996
  }
2026
- push$1.apply(results, setMatched);
1997
+ push.apply(results, setMatched);
2027
1998
  if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) {
2028
1999
  Sizzle.uniqueSort(results);
2029
2000
  }
@@ -2081,7 +2052,7 @@
2081
2052
  tokens.splice(i, 1);
2082
2053
  selector = seed.length && toSelector(tokens);
2083
2054
  if (!selector) {
2084
- push$1.apply(results, seed);
2055
+ push.apply(results, seed);
2085
2056
  return results;
2086
2057
  }
2087
2058
  break;
@@ -2381,7 +2352,7 @@
2381
2352
  _addCacheSuffix: _addCacheSuffix
2382
2353
  };
2383
2354
 
2384
- var doc = domGlobals.document, push$2 = Array.prototype.push, slice$2 = Array.prototype.slice;
2355
+ var doc = domGlobals.document, push$1 = Array.prototype.push, slice$1 = Array.prototype.slice;
2385
2356
  var rquickExpr$1 = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/;
2386
2357
  var Event = EventUtils.Event;
2387
2358
  var skipUniques = Tools.makeMap('children,contents,next,prev');
@@ -2559,7 +2530,7 @@
2559
2530
  if (match[1]) {
2560
2531
  node = createFragment(selector, getElementDocument(context)).firstChild;
2561
2532
  while (node) {
2562
- push$2.call(self, node);
2533
+ push$1.call(self, node);
2563
2534
  node = node.nextSibling;
2564
2535
  }
2565
2536
  } else {
@@ -2597,7 +2568,7 @@
2597
2568
  self[i] = nodes[i];
2598
2569
  }
2599
2570
  } else {
2600
- push$2.apply(self, DomQuery.makeArray(items));
2571
+ push$1.apply(self, DomQuery.makeArray(items));
2601
2572
  }
2602
2573
  return self;
2603
2574
  },
@@ -2914,7 +2885,7 @@
2914
2885
  return this.css('display', 'none');
2915
2886
  },
2916
2887
  slice: function () {
2917
- return new DomQuery(slice$2.apply(this, arguments));
2888
+ return new DomQuery(slice$1.apply(this, arguments));
2918
2889
  },
2919
2890
  eq: function (index) {
2920
2891
  return index === -1 ? this.slice(index) : this.slice(index, +index + 1);
@@ -2981,7 +2952,7 @@
2981
2952
  }
2982
2953
  return this.css(offset);
2983
2954
  },
2984
- push: push$2,
2955
+ push: push$1,
2985
2956
  sort: [].sort,
2986
2957
  splice: [].splice
2987
2958
  };
@@ -3645,21 +3616,21 @@
3645
3616
  for (var k = 0, len = props.length; k < len; k++) {
3646
3617
  var i = props[k];
3647
3618
  var x = obj[i];
3648
- f(x, i, obj);
3619
+ f(x, i);
3649
3620
  }
3650
3621
  };
3651
3622
  var map$2 = function (obj, f) {
3652
- return tupleMap(obj, function (x, i, obj) {
3623
+ return tupleMap(obj, function (x, i) {
3653
3624
  return {
3654
3625
  k: i,
3655
- v: f(x, i, obj)
3626
+ v: f(x, i)
3656
3627
  };
3657
3628
  });
3658
3629
  };
3659
3630
  var tupleMap = function (obj, f) {
3660
3631
  var r = {};
3661
3632
  each$3(obj, function (x, i) {
3662
- var tuple = f(x, i, obj);
3633
+ var tuple = f(x, i);
3663
3634
  r[tuple.k] = tuple.v;
3664
3635
  });
3665
3636
  return r;
@@ -3750,6 +3721,17 @@
3750
3721
  return r.length > 0;
3751
3722
  });
3752
3723
  };
3724
+ var getAllRaw = function (element) {
3725
+ var css = {};
3726
+ var dom = element.dom();
3727
+ if (isSupported(dom)) {
3728
+ for (var i = 0; i < dom.style.length; i++) {
3729
+ var ruleName = dom.style.item(i);
3730
+ css[ruleName] = dom.style[ruleName];
3731
+ }
3732
+ }
3733
+ return css;
3734
+ };
3753
3735
 
3754
3736
  var Immutable = function () {
3755
3737
  var fields = [];
@@ -5675,7 +5657,7 @@
5675
5657
  textBlockElementsMap = createLookupTable('text_block_elements', 'h1 h2 h3 h4 h5 h6 p div address pre form ' + 'blockquote center dir fieldset header footer article section hgroup aside main nav figure');
5676
5658
  blockElementsMap = createLookupTable('block_elements', 'hr table tbody thead tfoot ' + 'th tr td li ol ul caption dl dt dd noscript menu isindex option ' + 'datalist select optgroup figcaption details summary', textBlockElementsMap);
5677
5659
  textInlineElementsMap = createLookupTable('text_inline_elements', 'span strong b em i font strike u var cite ' + 'dfn code mark q sup sub samp');
5678
- each$4((settings.special || 'script noscript noframes noembed title style textarea xmp').split(' '), function (name) {
5660
+ each$4((settings.special || 'script noscript iframe noframes noembed title style textarea xmp').split(' '), function (name) {
5679
5661
  specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi');
5680
5662
  });
5681
5663
  var patternToRegExp = function (str) {
@@ -6682,12 +6664,14 @@
6682
6664
  var node;
6683
6665
  var container = doc.createElement('div');
6684
6666
  var frag = doc.createDocumentFragment();
6667
+ frag.appendChild(container);
6685
6668
  if (html) {
6686
6669
  container.innerHTML = html;
6687
6670
  }
6688
6671
  while (node = container.firstChild) {
6689
6672
  frag.appendChild(node);
6690
6673
  }
6674
+ frag.removeChild(container);
6691
6675
  return frag;
6692
6676
  };
6693
6677
  var remove = function (node, keepChildren) {
@@ -7819,6 +7803,18 @@
7819
7803
  };
7820
7804
  };
7821
7805
 
7806
+ var __assign = function () {
7807
+ __assign = Object.assign || function __assign(t) {
7808
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
7809
+ s = arguments[i];
7810
+ for (var p in s)
7811
+ if (Object.prototype.hasOwnProperty.call(s, p))
7812
+ t[p] = s[p];
7813
+ }
7814
+ return t;
7815
+ };
7816
+ return __assign.apply(this, arguments);
7817
+ };
7822
7818
  function __rest(s, e) {
7823
7819
  var t = {};
7824
7820
  for (var p in s)
@@ -7831,6 +7827,14 @@
7831
7827
  }
7832
7828
  return t;
7833
7829
  }
7830
+ function __spreadArrays() {
7831
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++)
7832
+ s += arguments[i].length;
7833
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
7834
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
7835
+ r[k] = a[j];
7836
+ return r;
7837
+ }
7834
7838
 
7835
7839
  var unique = 0;
7836
7840
  var generate = function (prefix) {
@@ -8099,7 +8103,8 @@
8099
8103
  return overflowY >= 0 && overflowY <= Math.min(rect1.height, rect2.height) / 2;
8100
8104
  };
8101
8105
  var isAbove = function (rect1, rect2) {
8102
- if (rect1.bottom - rect1.height / 2 < rect2.top) {
8106
+ var halfHeight = Math.min(rect2.height / 2, rect1.height / 2);
8107
+ if (rect1.bottom - halfHeight < rect2.top) {
8103
8108
  return true;
8104
8109
  }
8105
8110
  if (rect1.top > rect2.bottom) {
@@ -8162,26 +8167,20 @@
8162
8167
  return typeof ch === 'string' && ch.charCodeAt(0) >= 768 && extendingChars.test(ch);
8163
8168
  };
8164
8169
 
8165
- var liftN = function (arr, f) {
8166
- var r = [];
8167
- for (var i = 0; i < arr.length; i++) {
8168
- var x = arr[i];
8169
- if (x.isSome()) {
8170
- r.push(x.getOrDie());
8171
- } else {
8172
- return Option.none();
8173
- }
8174
- }
8175
- return Option.some(f.apply(null, r));
8170
+ var lift2 = function (oa, ob, f) {
8171
+ return oa.isSome() && ob.isSome() ? Option.some(f(oa.getOrDie(), ob.getOrDie())) : Option.none();
8172
+ };
8173
+ var lift3 = function (oa, ob, oc, f) {
8174
+ return oa.isSome() && ob.isSome() && oc.isSome() ? Option.some(f(oa.getOrDie(), ob.getOrDie(), oc.getOrDie())) : Option.none();
8176
8175
  };
8177
8176
 
8178
- var slice$3 = [].slice;
8177
+ var slice$2 = [].slice;
8179
8178
  var or = function () {
8180
8179
  var x = [];
8181
8180
  for (var _i = 0; _i < arguments.length; _i++) {
8182
8181
  x[_i] = arguments[_i];
8183
8182
  }
8184
- var args = slice$3.call(arguments);
8183
+ var args = slice$2.call(arguments);
8185
8184
  return function (x) {
8186
8185
  for (var i = 0; i < args.length; i++) {
8187
8186
  if (args[i](x)) {
@@ -8196,7 +8195,7 @@
8196
8195
  for (var _i = 0; _i < arguments.length; _i++) {
8197
8196
  x[_i] = arguments[_i];
8198
8197
  }
8199
- var args = slice$3.call(arguments);
8198
+ var args = slice$2.call(arguments);
8200
8199
  return function (x) {
8201
8200
  for (var i = 0; i < args.length; i++) {
8202
8201
  if (!args[i](x)) {
@@ -8433,16 +8432,10 @@
8433
8432
  return CaretPosition(node.parentNode, nodeIndex(node));
8434
8433
  };
8435
8434
  CaretPosition.isAbove = function (pos1, pos2) {
8436
- return liftN([
8437
- head(pos2.getClientRects()),
8438
- last(pos1.getClientRects())
8439
- ], isAbove).getOr(false);
8435
+ return lift2(head(pos2.getClientRects()), last(pos1.getClientRects()), isAbove).getOr(false);
8440
8436
  };
8441
8437
  CaretPosition.isBelow = function (pos1, pos2) {
8442
- return liftN([
8443
- last(pos2.getClientRects()),
8444
- head(pos1.getClientRects())
8445
- ], isBelow).getOr(false);
8438
+ return lift2(last(pos2.getClientRects()), head(pos1.getClientRects()), isBelow).getOr(false);
8446
8439
  };
8447
8440
  CaretPosition.isAtStart = function (pos) {
8448
8441
  return pos ? pos.isAtStart() : false;
@@ -9556,7 +9549,7 @@
9556
9549
  };
9557
9550
 
9558
9551
  var addBogus = function (dom, node) {
9559
- if (dom.isBlock(node) && !node.innerHTML && !Env.ie) {
9552
+ if (NodeType.isElement(node) && dom.isBlock(node) && !node.innerHTML && !Env.ie) {
9560
9553
  node.innerHTML = '<br data-mce-bogus="1" />';
9561
9554
  }
9562
9555
  return node;
@@ -9719,10 +9712,7 @@
9719
9712
  var resolveId = function (dom, bookmark) {
9720
9713
  var startPos = restoreEndPoint(dom, 'start', bookmark);
9721
9714
  var endPos = restoreEndPoint(dom, 'end', bookmark);
9722
- return liftN([
9723
- startPos,
9724
- alt(endPos, startPos)
9725
- ], function (spos, epos) {
9715
+ return lift2(startPos, alt(endPos, startPos), function (spos, epos) {
9726
9716
  var rng = dom.createRng();
9727
9717
  rng.setStart(addBogus(dom, spos.container()), spos.offset());
9728
9718
  rng.setEnd(addBogus(dom, epos.container()), epos.offset());
@@ -11368,10 +11358,7 @@
11368
11358
  }
11369
11359
  };
11370
11360
  var willDeleteLastPositionInElement = function (forward, fromPos, elm) {
11371
- return liftN([
11372
- CaretFinder.firstPositionIn(elm),
11373
- CaretFinder.lastPositionIn(elm)
11374
- ], function (firstPos, lastPos) {
11361
+ return lift2(CaretFinder.firstPositionIn(elm), CaretFinder.lastPositionIn(elm), function (firstPos, lastPos) {
11375
11362
  var normalizedFirstPos = InlineUtils.normalizePosition(true, firstPos);
11376
11363
  var normalizedLastPos = InlineUtils.normalizePosition(false, lastPos);
11377
11364
  var normalizedFromPos = InlineUtils.normalizePosition(false, fromPos);
@@ -11470,7 +11457,7 @@
11470
11457
  }).isSome();
11471
11458
  };
11472
11459
  var isEditable = function (blockBoundary) {
11473
- return NodeType.isContentEditableFalse(blockBoundary.from().block()) === false && NodeType.isContentEditableFalse(blockBoundary.to().block()) === false;
11460
+ return NodeType.isContentEditableFalse(blockBoundary.from().block().dom()) === false && NodeType.isContentEditableFalse(blockBoundary.to().block().dom()) === false;
11474
11461
  };
11475
11462
  var skipLastBr = function (rootNode, forward, blockPosition) {
11476
11463
  if (NodeType.isBr(blockPosition.position().getNode()) && Empty.isEmpty(blockPosition.block()) === false) {
@@ -11496,10 +11483,7 @@
11496
11483
  });
11497
11484
  });
11498
11485
  });
11499
- return liftN([
11500
- fromBlockPos,
11501
- toBlockPos
11502
- ], BlockBoundary).filter(function (blockBoundary) {
11486
+ return lift2(fromBlockPos, toBlockPos, BlockBoundary).filter(function (blockBoundary) {
11503
11487
  return isDifferentBlocks(blockBoundary) && hasSameParent(blockBoundary) && isEditable(blockBoundary);
11504
11488
  });
11505
11489
  };
@@ -11621,10 +11605,7 @@
11621
11605
 
11622
11606
  var deleteRangeMergeBlocks = function (rootNode, selection) {
11623
11607
  var rng = selection.getRng();
11624
- return liftN([
11625
- DeleteUtils.getParentBlock(rootNode, Element.fromDom(rng.startContainer)),
11626
- DeleteUtils.getParentBlock(rootNode, Element.fromDom(rng.endContainer))
11627
- ], function (block1, block2) {
11608
+ return lift2(DeleteUtils.getParentBlock(rootNode, Element.fromDom(rng.startContainer)), DeleteUtils.getParentBlock(rootNode, Element.fromDom(rng.endContainer)), function (block1, block2) {
11628
11609
  if (eq(block1, block2) === false) {
11629
11610
  rng.deleteContents();
11630
11611
  MergeBlocks.mergeBlocks(rootNode, true, block1, block2).each(function (pos) {
@@ -12035,11 +12016,7 @@
12035
12016
  var prevTextOpt = prevSibling(elm).filter(isText);
12036
12017
  var nextTextOpt = nextSibling(elm).filter(isText);
12037
12018
  remove$1(elm);
12038
- return liftN([
12039
- prevTextOpt,
12040
- nextTextOpt,
12041
- afterDeletePosOpt
12042
- ], function (prev, next, pos) {
12019
+ return lift3(prevTextOpt, nextTextOpt, afterDeletePosOpt, function (prev, next, pos) {
12043
12020
  var prevNode = prev.dom(), nextNode = next.dom();
12044
12021
  var offset = prevNode.data.length;
12045
12022
  mergeTextNodes(prevNode, nextNode, normalizeWhitespace);
@@ -12356,10 +12333,7 @@
12356
12333
  return getName(location1) === getName(location2) && getElement(location1) === getElement(location2);
12357
12334
  };
12358
12335
  var betweenInlines = function (forward, isInlineTarget, rootNode, from, to, location) {
12359
- return liftN([
12360
- InlineUtils.findRootInline(isInlineTarget, rootNode, from),
12361
- InlineUtils.findRootInline(isInlineTarget, rootNode, to)
12362
- ], function (fromInline, toInline) {
12336
+ return lift2(InlineUtils.findRootInline(isInlineTarget, rootNode, from), InlineUtils.findRootInline(isInlineTarget, rootNode, to), function (fromInline, toInline) {
12363
12337
  if (fromInline !== toInline && InlineUtils.hasSameParentBlock(rootNode, fromInline, toInline)) {
12364
12338
  return Location.after(forward ? fromInline : toInline);
12365
12339
  } else {
@@ -12532,10 +12506,7 @@
12532
12506
  return range;
12533
12507
  };
12534
12508
  var hasOnlyTwoOrLessPositionsLeft = function (elm) {
12535
- return liftN([
12536
- CaretFinder.firstPositionIn(elm),
12537
- CaretFinder.lastPositionIn(elm)
12538
- ], function (firstPos, lastPos) {
12509
+ return lift2(CaretFinder.firstPositionIn(elm), CaretFinder.lastPositionIn(elm), function (firstPos, lastPos) {
12539
12510
  var normalizedFirstPos = InlineUtils.normalizePosition(true, firstPos);
12540
12511
  var normalizedLastPos = InlineUtils.normalizePosition(false, lastPos);
12541
12512
  return CaretFinder.nextPosition(elm, normalizedFirstPos).map(function (pos) {
@@ -12650,10 +12621,7 @@
12650
12621
  var partialSelection = function (isRoot, rng) {
12651
12622
  var startCell = getClosestCell(rng.startContainer, isRoot);
12652
12623
  var endCell = getClosestCell(rng.endContainer, isRoot);
12653
- return rng.collapsed ? Option.none() : liftN([
12654
- startCell,
12655
- endCell
12656
- ], tableCellRng).fold(function () {
12624
+ return rng.collapsed ? Option.none() : lift2(startCell, endCell, tableCellRng).fold(function () {
12657
12625
  return startCell.fold(function () {
12658
12626
  return endCell.bind(function (endCell) {
12659
12627
  return getClosestTable(endCell, isRoot).bind(function (table) {
@@ -12679,10 +12647,7 @@
12679
12647
  var getCellRng = function (rng, isRoot) {
12680
12648
  var startCell = getClosestCell(rng.startContainer, isRoot);
12681
12649
  var endCell = getClosestCell(rng.endContainer, isRoot);
12682
- return liftN([
12683
- startCell,
12684
- endCell
12685
- ], tableCellRng).filter(isExpandedCellRng).filter(function (cellRng) {
12650
+ return lift2(startCell, endCell, tableCellRng).filter(isExpandedCellRng).filter(function (cellRng) {
12686
12651
  return isWithinSameTable(isRoot, cellRng);
12687
12652
  }).orThunk(function () {
12688
12653
  return partialSelection(isRoot, rng);
@@ -12705,10 +12670,7 @@
12705
12670
  });
12706
12671
  };
12707
12672
  var getSelectedCells = function (tableSelection) {
12708
- return liftN([
12709
- getCellIndex(tableSelection.cells(), tableSelection.rng().start()),
12710
- getCellIndex(tableSelection.cells(), tableSelection.rng().end())
12711
- ], function (startIndex, endIndex) {
12673
+ return lift2(getCellIndex(tableSelection.cells(), tableSelection.rng().start()), getCellIndex(tableSelection.cells(), tableSelection.rng().end()), function (startIndex, endIndex) {
12712
12674
  return tableSelection.cells().slice(startIndex, endIndex + 1);
12713
12675
  });
12714
12676
  };
@@ -13329,6 +13291,99 @@
13329
13291
  };
13330
13292
  var InlineFormatDelete = { backspaceDelete: backspaceDelete$5 };
13331
13293
 
13294
+ var getPos$1 = function (elm) {
13295
+ var x = 0, y = 0;
13296
+ var offsetParent = elm;
13297
+ while (offsetParent && offsetParent.nodeType) {
13298
+ x += offsetParent.offsetLeft || 0;
13299
+ y += offsetParent.offsetTop || 0;
13300
+ offsetParent = offsetParent.offsetParent;
13301
+ }
13302
+ return {
13303
+ x: x,
13304
+ y: y
13305
+ };
13306
+ };
13307
+ var fireScrollIntoViewEvent = function (editor, elm, alignToTop) {
13308
+ var scrollEvent = {
13309
+ elm: elm,
13310
+ alignToTop: alignToTop
13311
+ };
13312
+ editor.fire('scrollIntoView', scrollEvent);
13313
+ return scrollEvent.isDefaultPrevented();
13314
+ };
13315
+ var scrollElementIntoView = function (editor, elm, alignToTop) {
13316
+ var y, viewPort;
13317
+ var dom = editor.dom;
13318
+ var root = dom.getRoot();
13319
+ var viewPortY, viewPortH, offsetY = 0;
13320
+ if (fireScrollIntoViewEvent(editor, elm, alignToTop)) {
13321
+ return;
13322
+ }
13323
+ if (!NodeType.isElement(elm)) {
13324
+ return;
13325
+ }
13326
+ if (alignToTop === false) {
13327
+ offsetY = elm.offsetHeight;
13328
+ }
13329
+ if (root.nodeName !== 'BODY') {
13330
+ var scrollContainer = editor.selection.getScrollContainer();
13331
+ if (scrollContainer) {
13332
+ y = getPos$1(elm).y - getPos$1(scrollContainer).y + offsetY;
13333
+ viewPortH = scrollContainer.clientHeight;
13334
+ viewPortY = scrollContainer.scrollTop;
13335
+ if (y < viewPortY || y + 25 > viewPortY + viewPortH) {
13336
+ scrollContainer.scrollTop = y < viewPortY ? y : y - viewPortH + 25;
13337
+ }
13338
+ return;
13339
+ }
13340
+ }
13341
+ viewPort = dom.getViewPort(editor.getWin());
13342
+ y = dom.getPos(elm).y + offsetY;
13343
+ viewPortY = viewPort.y;
13344
+ viewPortH = viewPort.h;
13345
+ if (y < viewPort.y || y + 25 > viewPortY + viewPortH) {
13346
+ editor.getWin().scrollTo(0, y < viewPortY ? y : y - viewPortH + 25);
13347
+ }
13348
+ };
13349
+ var getViewPortRect = function (editor) {
13350
+ if (editor.inline) {
13351
+ return editor.getBody().getBoundingClientRect();
13352
+ } else {
13353
+ var win = editor.getWin();
13354
+ return {
13355
+ left: 0,
13356
+ right: win.innerWidth,
13357
+ top: 0,
13358
+ bottom: win.innerHeight,
13359
+ width: win.innerWidth,
13360
+ height: win.innerHeight
13361
+ };
13362
+ }
13363
+ };
13364
+ var scrollBy = function (editor, dx, dy) {
13365
+ if (editor.inline) {
13366
+ editor.getBody().scrollLeft += dx;
13367
+ editor.getBody().scrollTop += dy;
13368
+ } else {
13369
+ editor.getWin().scrollBy(dx, dy);
13370
+ }
13371
+ };
13372
+ var scrollRangeIntoView = function (editor, rng) {
13373
+ head(CaretPosition.fromRangeStart(rng).getClientRects()).each(function (rngRect) {
13374
+ var bodyRect = getViewPortRect(editor);
13375
+ var overflow = getOverflow(bodyRect, rngRect);
13376
+ var margin = 4;
13377
+ var dx = overflow.x > 0 ? overflow.x + margin : overflow.x - margin;
13378
+ var dy = overflow.y > 0 ? overflow.y + margin : overflow.y - margin;
13379
+ scrollBy(editor, overflow.x !== 0 ? dx : 0, overflow.y !== 0 ? dy : 0);
13380
+ });
13381
+ };
13382
+ var ScrollIntoView = {
13383
+ scrollElementIntoView: scrollElementIntoView,
13384
+ scrollRangeIntoView: scrollRangeIntoView
13385
+ };
13386
+
13332
13387
  var isContentEditableTrue$2 = NodeType.isContentEditableTrue;
13333
13388
  var isContentEditableFalse$6 = NodeType.isContentEditableFalse;
13334
13389
  var showCaret = function (direction, editor, node, before, scrollIntoView) {
@@ -13375,6 +13430,10 @@
13375
13430
  }
13376
13431
  return range;
13377
13432
  };
13433
+ var moveToRange = function (editor, rng) {
13434
+ editor.selection.setRng(rng);
13435
+ ScrollIntoView.scrollRangeIntoView(editor, editor.selection.getRng());
13436
+ };
13378
13437
 
13379
13438
  var trimEmptyTextNode$1 = function (dom, node) {
13380
13439
  if (NodeType.isText(node) && node.data.length === 0) {
@@ -16508,10 +16567,7 @@
16508
16567
  });
16509
16568
  };
16510
16569
  var hasAllContentsSelected = function (elm, rng) {
16511
- return liftN([
16512
- getStartNode(rng),
16513
- getEndNode(rng)
16514
- ], function (startNode, endNode) {
16570
+ return lift2(getStartNode(rng), getEndNode(rng), function (startNode, endNode) {
16515
16571
  var start = find(getFirstChildren(elm), curry(eq, startNode));
16516
16572
  var end = find(getLastChildren$1(elm), curry(eq, endNode));
16517
16573
  return start.isSome() && end.isSome();
@@ -16645,288 +16701,42 @@
16645
16701
  };
16646
16702
  }
16647
16703
 
16648
- var getAbsolutePosition = function (elm) {
16649
- var doc, docElem, win, clientRect;
16650
- clientRect = elm.getBoundingClientRect();
16651
- doc = elm.ownerDocument;
16652
- docElem = doc.documentElement;
16653
- win = doc.defaultView;
16654
- return {
16655
- top: clientRect.top + win.pageYOffset - docElem.clientTop,
16656
- left: clientRect.left + win.pageXOffset - docElem.clientLeft
16657
- };
16658
- };
16659
- var getBodyPosition = function (editor) {
16660
- return editor.inline ? getAbsolutePosition(editor.getBody()) : {
16661
- left: 0,
16662
- top: 0
16663
- };
16664
- };
16665
- var getScrollPosition = function (editor) {
16666
- var body = editor.getBody();
16667
- return editor.inline ? {
16668
- left: body.scrollLeft,
16669
- top: body.scrollTop
16670
- } : {
16671
- left: 0,
16672
- top: 0
16673
- };
16674
- };
16675
- var getBodyScroll = function (editor) {
16676
- var body = editor.getBody(), docElm = editor.getDoc().documentElement;
16677
- var inlineScroll = {
16678
- left: body.scrollLeft,
16679
- top: body.scrollTop
16680
- };
16681
- var iframeScroll = {
16682
- left: body.scrollLeft || docElm.scrollLeft,
16683
- top: body.scrollTop || docElm.scrollTop
16684
- };
16685
- return editor.inline ? inlineScroll : iframeScroll;
16686
- };
16687
- var getMousePosition = function (editor, event) {
16688
- if (event.target.ownerDocument !== editor.getDoc()) {
16689
- var iframePosition = getAbsolutePosition(editor.getContentAreaContainer());
16690
- var scrollPosition = getBodyScroll(editor);
16691
- return {
16692
- left: event.pageX - iframePosition.left + scrollPosition.left,
16693
- top: event.pageY - iframePosition.top + scrollPosition.top
16694
- };
16704
+ var VK = {
16705
+ BACKSPACE: 8,
16706
+ DELETE: 46,
16707
+ DOWN: 40,
16708
+ ENTER: 13,
16709
+ LEFT: 37,
16710
+ RIGHT: 39,
16711
+ SPACEBAR: 32,
16712
+ TAB: 9,
16713
+ UP: 38,
16714
+ END: 35,
16715
+ HOME: 36,
16716
+ modifierPressed: function (e) {
16717
+ return e.shiftKey || e.ctrlKey || e.altKey || this.metaKeyPressed(e);
16718
+ },
16719
+ metaKeyPressed: function (e) {
16720
+ return Env.mac ? e.metaKey : e.ctrlKey && !e.altKey;
16695
16721
  }
16696
- return {
16697
- left: event.pageX,
16698
- top: event.pageY
16699
- };
16700
- };
16701
- var calculatePosition = function (bodyPosition, scrollPosition, mousePosition) {
16702
- return {
16703
- pageX: mousePosition.left - bodyPosition.left + scrollPosition.left,
16704
- pageY: mousePosition.top - bodyPosition.top + scrollPosition.top
16705
- };
16706
16722
  };
16707
- var calc = function (editor, event) {
16708
- return calculatePosition(getBodyPosition(editor), getScrollPosition(editor), getMousePosition(editor, event));
16709
- };
16710
- var MousePosition = { calc: calc };
16711
16723
 
16712
- var isContentEditableFalse$7 = NodeType.isContentEditableFalse, isContentEditableTrue$3 = NodeType.isContentEditableTrue;
16713
- var isDraggable = function (rootElm, elm) {
16714
- return isContentEditableFalse$7(elm) && elm !== rootElm;
16715
- };
16716
- var isValidDropTarget = function (editor, targetElement, dragElement) {
16717
- if (targetElement === dragElement || editor.dom.isChildOf(targetElement, dragElement)) {
16718
- return false;
16724
+ var getNodeClientRects = function (node) {
16725
+ var toArrayWithNode = function (clientRects) {
16726
+ return map(clientRects, function (clientRect) {
16727
+ clientRect = clone$1(clientRect);
16728
+ clientRect.node = node;
16729
+ return clientRect;
16730
+ });
16731
+ };
16732
+ if (NodeType.isElement(node)) {
16733
+ return toArrayWithNode(node.getClientRects());
16719
16734
  }
16720
- if (isContentEditableFalse$7(targetElement)) {
16721
- return false;
16722
- }
16723
- return true;
16724
- };
16725
- var cloneElement = function (elm) {
16726
- var cloneElm = elm.cloneNode(true);
16727
- cloneElm.removeAttribute('data-mce-selected');
16728
- return cloneElm;
16729
- };
16730
- var createGhost = function (editor, elm, width, height) {
16731
- var clonedElm = elm.cloneNode(true);
16732
- editor.dom.setStyles(clonedElm, {
16733
- width: width,
16734
- height: height
16735
- });
16736
- editor.dom.setAttrib(clonedElm, 'data-mce-selected', null);
16737
- var ghostElm = editor.dom.create('div', {
16738
- 'class': 'mce-drag-container',
16739
- 'data-mce-bogus': 'all',
16740
- 'unselectable': 'on',
16741
- 'contenteditable': 'false'
16742
- });
16743
- editor.dom.setStyles(ghostElm, {
16744
- position: 'absolute',
16745
- opacity: 0.5,
16746
- overflow: 'hidden',
16747
- border: 0,
16748
- padding: 0,
16749
- margin: 0,
16750
- width: width,
16751
- height: height
16752
- });
16753
- editor.dom.setStyles(clonedElm, {
16754
- margin: 0,
16755
- boxSizing: 'border-box'
16756
- });
16757
- ghostElm.appendChild(clonedElm);
16758
- return ghostElm;
16759
- };
16760
- var appendGhostToBody = function (ghostElm, bodyElm) {
16761
- if (ghostElm.parentNode !== bodyElm) {
16762
- bodyElm.appendChild(ghostElm);
16763
- }
16764
- };
16765
- var moveGhost = function (ghostElm, position, width, height, maxX, maxY) {
16766
- var overflowX = 0, overflowY = 0;
16767
- ghostElm.style.left = position.pageX + 'px';
16768
- ghostElm.style.top = position.pageY + 'px';
16769
- if (position.pageX + width > maxX) {
16770
- overflowX = position.pageX + width - maxX;
16771
- }
16772
- if (position.pageY + height > maxY) {
16773
- overflowY = position.pageY + height - maxY;
16774
- }
16775
- ghostElm.style.width = width - overflowX + 'px';
16776
- ghostElm.style.height = height - overflowY + 'px';
16777
- };
16778
- var removeElement = function (elm) {
16779
- if (elm && elm.parentNode) {
16780
- elm.parentNode.removeChild(elm);
16781
- }
16782
- };
16783
- var isLeftMouseButtonPressed = function (e) {
16784
- return e.button === 0;
16785
- };
16786
- var hasDraggableElement = function (state) {
16787
- return state.element;
16788
- };
16789
- var applyRelPos = function (state, position) {
16790
- return {
16791
- pageX: position.pageX - state.relX,
16792
- pageY: position.pageY + 5
16793
- };
16794
- };
16795
- var start$1 = function (state, editor) {
16796
- return function (e) {
16797
- if (isLeftMouseButtonPressed(e)) {
16798
- var ceElm = find(editor.dom.getParents(e.target), Predicate.or(isContentEditableFalse$7, isContentEditableTrue$3)).getOr(null);
16799
- if (isDraggable(editor.getBody(), ceElm)) {
16800
- var elmPos = editor.dom.getPos(ceElm);
16801
- var bodyElm = editor.getBody();
16802
- var docElm = editor.getDoc().documentElement;
16803
- state.element = ceElm;
16804
- state.screenX = e.screenX;
16805
- state.screenY = e.screenY;
16806
- state.maxX = (editor.inline ? bodyElm.scrollWidth : docElm.offsetWidth) - 2;
16807
- state.maxY = (editor.inline ? bodyElm.scrollHeight : docElm.offsetHeight) - 2;
16808
- state.relX = e.pageX - elmPos.x;
16809
- state.relY = e.pageY - elmPos.y;
16810
- state.width = ceElm.offsetWidth;
16811
- state.height = ceElm.offsetHeight;
16812
- state.ghost = createGhost(editor, ceElm, state.width, state.height);
16813
- }
16814
- }
16815
- };
16816
- };
16817
- var move$1 = function (state, editor) {
16818
- var throttledPlaceCaretAt = Delay.throttle(function (clientX, clientY) {
16819
- editor._selectionOverrides.hideFakeCaret();
16820
- editor.selection.placeCaretAt(clientX, clientY);
16821
- }, 0);
16822
- return function (e) {
16823
- var movement = Math.max(Math.abs(e.screenX - state.screenX), Math.abs(e.screenY - state.screenY));
16824
- if (hasDraggableElement(state) && !state.dragging && movement > 10) {
16825
- var args = editor.fire('dragstart', { target: state.element });
16826
- if (args.isDefaultPrevented()) {
16827
- return;
16828
- }
16829
- state.dragging = true;
16830
- editor.focus();
16831
- }
16832
- if (state.dragging) {
16833
- var targetPos = applyRelPos(state, MousePosition.calc(editor, e));
16834
- appendGhostToBody(state.ghost, editor.getBody());
16835
- moveGhost(state.ghost, targetPos, state.width, state.height, state.maxX, state.maxY);
16836
- throttledPlaceCaretAt(e.clientX, e.clientY);
16837
- }
16838
- };
16839
- };
16840
- var getRawTarget = function (selection) {
16841
- var rng = selection.getSel().getRangeAt(0);
16842
- var startContainer = rng.startContainer;
16843
- return startContainer.nodeType === 3 ? startContainer.parentNode : startContainer;
16844
- };
16845
- var drop = function (state, editor) {
16846
- return function (e) {
16847
- if (state.dragging) {
16848
- if (isValidDropTarget(editor, getRawTarget(editor.selection), state.element)) {
16849
- var targetClone_1 = cloneElement(state.element);
16850
- var args = editor.fire('drop', {
16851
- targetClone: targetClone_1,
16852
- clientX: e.clientX,
16853
- clientY: e.clientY
16854
- });
16855
- if (!args.isDefaultPrevented()) {
16856
- targetClone_1 = args.targetClone;
16857
- editor.undoManager.transact(function () {
16858
- removeElement(state.element);
16859
- editor.insertContent(editor.dom.getOuterHTML(targetClone_1));
16860
- editor._selectionOverrides.hideFakeCaret();
16861
- });
16862
- }
16863
- }
16864
- }
16865
- removeDragState(state);
16866
- };
16867
- };
16868
- var stop = function (state, editor) {
16869
- return function () {
16870
- if (state.dragging) {
16871
- editor.fire('dragend');
16872
- }
16873
- removeDragState(state);
16874
- };
16875
- };
16876
- var removeDragState = function (state) {
16877
- state.dragging = false;
16878
- state.element = null;
16879
- removeElement(state.ghost);
16880
- };
16881
- var bindFakeDragEvents = function (editor) {
16882
- var state = {};
16883
- var pageDom, dragStartHandler, dragHandler, dropHandler, dragEndHandler, rootDocument;
16884
- pageDom = DOMUtils$1.DOM;
16885
- rootDocument = domGlobals.document;
16886
- dragStartHandler = start$1(state, editor);
16887
- dragHandler = move$1(state, editor);
16888
- dropHandler = drop(state, editor);
16889
- dragEndHandler = stop(state, editor);
16890
- editor.on('mousedown', dragStartHandler);
16891
- editor.on('mousemove', dragHandler);
16892
- editor.on('mouseup', dropHandler);
16893
- pageDom.bind(rootDocument, 'mousemove', dragHandler);
16894
- pageDom.bind(rootDocument, 'mouseup', dragEndHandler);
16895
- editor.on('remove', function () {
16896
- pageDom.unbind(rootDocument, 'mousemove', dragHandler);
16897
- pageDom.unbind(rootDocument, 'mouseup', dragEndHandler);
16898
- });
16899
- };
16900
- var blockIeDrop = function (editor) {
16901
- editor.on('drop', function (e) {
16902
- var realTarget = typeof e.clientX !== 'undefined' ? editor.getDoc().elementFromPoint(e.clientX, e.clientY) : null;
16903
- if (isContentEditableFalse$7(realTarget) || isContentEditableFalse$7(editor.dom.getContentEditableParent(realTarget))) {
16904
- e.preventDefault();
16905
- }
16906
- });
16907
- };
16908
- var init = function (editor) {
16909
- bindFakeDragEvents(editor);
16910
- blockIeDrop(editor);
16911
- };
16912
- var DragDropOverrides = { init: init };
16913
-
16914
- var getNodeClientRects = function (node) {
16915
- var toArrayWithNode = function (clientRects) {
16916
- return map(clientRects, function (clientRect) {
16917
- clientRect = clone$1(clientRect);
16918
- clientRect.node = node;
16919
- return clientRect;
16920
- });
16921
- };
16922
- if (NodeType.isElement(node)) {
16923
- return toArrayWithNode(node.getClientRects());
16924
- }
16925
- if (NodeType.isText(node)) {
16926
- var rng = node.ownerDocument.createRange();
16927
- rng.setStart(node, 0);
16928
- rng.setEnd(node, node.data.length);
16929
- return toArrayWithNode(rng.getClientRects());
16735
+ if (NodeType.isText(node)) {
16736
+ var rng = node.ownerDocument.createRange();
16737
+ rng.setStart(node, 0);
16738
+ rng.setEnd(node, node.data.length);
16739
+ return toArrayWithNode(rng.getClientRects());
16930
16740
  }
16931
16741
  };
16932
16742
  var getClientRects = function (node) {
@@ -17044,7 +16854,7 @@
17044
16854
  };
17045
16855
  };
17046
16856
 
17047
- var isContentEditableFalse$8 = NodeType.isContentEditableFalse;
16857
+ var isContentEditableFalse$7 = NodeType.isContentEditableFalse;
17048
16858
  var findNode$1 = findNode;
17049
16859
  var distanceToRectLeft = function (clientRect, clientX) {
17050
16860
  return Math.abs(clientRect.left - clientX);
@@ -17066,79 +16876,345 @@
17066
16876
  if (isInside(clientX, oldClientRect)) {
17067
16877
  return oldClientRect;
17068
16878
  }
17069
- if (newDistance === oldDistance && isContentEditableFalse$8(clientRect.node)) {
16879
+ if (newDistance === oldDistance && isContentEditableFalse$7(clientRect.node)) {
17070
16880
  return clientRect;
17071
16881
  }
17072
16882
  if (newDistance < oldDistance) {
17073
16883
  return clientRect;
17074
16884
  }
17075
- return oldClientRect;
17076
- });
16885
+ return oldClientRect;
16886
+ });
16887
+ };
16888
+ var walkUntil$1 = function (direction, root, predicateFn, node) {
16889
+ while (node = findNode$1(node, direction, isEditableCaretCandidate, root)) {
16890
+ if (predicateFn(node)) {
16891
+ return;
16892
+ }
16893
+ }
16894
+ };
16895
+ var findLineNodeRects = function (root, targetNodeRect) {
16896
+ var clientRects = [];
16897
+ var collect = function (checkPosFn, node) {
16898
+ var lineRects;
16899
+ lineRects = filter(getClientRects([node]), function (clientRect) {
16900
+ return !checkPosFn(clientRect, targetNodeRect);
16901
+ });
16902
+ clientRects = clientRects.concat(lineRects);
16903
+ return lineRects.length === 0;
16904
+ };
16905
+ clientRects.push(targetNodeRect);
16906
+ walkUntil$1(VDirection.Up, root, curry(collect, isAbove), targetNodeRect.node);
16907
+ walkUntil$1(VDirection.Down, root, curry(collect, isBelow), targetNodeRect.node);
16908
+ return clientRects;
16909
+ };
16910
+ var getFakeCaretTargets = function (root) {
16911
+ return filter(from$1(root.getElementsByTagName('*')), isFakeCaretTarget);
16912
+ };
16913
+ var caretInfo = function (clientRect, clientX) {
16914
+ return {
16915
+ node: clientRect.node,
16916
+ before: distanceToRectLeft(clientRect, clientX) < distanceToRectRight(clientRect, clientX)
16917
+ };
16918
+ };
16919
+ var closestCaret = function (root, clientX, clientY) {
16920
+ var closestNodeRect;
16921
+ var contentEditableFalseNodeRects = getClientRects(getFakeCaretTargets(root));
16922
+ var targetNodeRects = filter(contentEditableFalseNodeRects, function (rect) {
16923
+ return clientY >= rect.top && clientY <= rect.bottom;
16924
+ });
16925
+ closestNodeRect = findClosestClientRect(targetNodeRects, clientX);
16926
+ if (closestNodeRect) {
16927
+ closestNodeRect = findClosestClientRect(findLineNodeRects(root, closestNodeRect), clientX);
16928
+ if (closestNodeRect && isFakeCaretTarget(closestNodeRect.node)) {
16929
+ return caretInfo(closestNodeRect, clientX);
16930
+ }
16931
+ }
16932
+ return null;
16933
+ };
16934
+
16935
+ var isXYWithinRange = function (clientX, clientY, range) {
16936
+ if (range.collapsed) {
16937
+ return false;
16938
+ }
16939
+ if (Env.ie && Env.ie <= 11 && range.startOffset === range.endOffset - 1 && range.startContainer === range.endContainer) {
16940
+ var elm = range.startContainer.childNodes[range.startOffset];
16941
+ if (NodeType.isElement(elm)) {
16942
+ return exists(elm.getClientRects(), function (rect) {
16943
+ return containsXY(rect, clientX, clientY);
16944
+ });
16945
+ }
16946
+ }
16947
+ return exists(range.getClientRects(), function (rect) {
16948
+ return containsXY(rect, clientX, clientY);
16949
+ });
16950
+ };
16951
+ var RangePoint = { isXYWithinRange: isXYWithinRange };
16952
+
16953
+ var getAbsolutePosition = function (elm) {
16954
+ var doc, docElem, win, clientRect;
16955
+ clientRect = elm.getBoundingClientRect();
16956
+ doc = elm.ownerDocument;
16957
+ docElem = doc.documentElement;
16958
+ win = doc.defaultView;
16959
+ return {
16960
+ top: clientRect.top + win.pageYOffset - docElem.clientTop,
16961
+ left: clientRect.left + win.pageXOffset - docElem.clientLeft
16962
+ };
16963
+ };
16964
+ var getBodyPosition = function (editor) {
16965
+ return editor.inline ? getAbsolutePosition(editor.getBody()) : {
16966
+ left: 0,
16967
+ top: 0
16968
+ };
16969
+ };
16970
+ var getScrollPosition = function (editor) {
16971
+ var body = editor.getBody();
16972
+ return editor.inline ? {
16973
+ left: body.scrollLeft,
16974
+ top: body.scrollTop
16975
+ } : {
16976
+ left: 0,
16977
+ top: 0
16978
+ };
16979
+ };
16980
+ var getBodyScroll = function (editor) {
16981
+ var body = editor.getBody(), docElm = editor.getDoc().documentElement;
16982
+ var inlineScroll = {
16983
+ left: body.scrollLeft,
16984
+ top: body.scrollTop
16985
+ };
16986
+ var iframeScroll = {
16987
+ left: body.scrollLeft || docElm.scrollLeft,
16988
+ top: body.scrollTop || docElm.scrollTop
16989
+ };
16990
+ return editor.inline ? inlineScroll : iframeScroll;
16991
+ };
16992
+ var getMousePosition = function (editor, event) {
16993
+ if (event.target.ownerDocument !== editor.getDoc()) {
16994
+ var iframePosition = getAbsolutePosition(editor.getContentAreaContainer());
16995
+ var scrollPosition = getBodyScroll(editor);
16996
+ return {
16997
+ left: event.pageX - iframePosition.left + scrollPosition.left,
16998
+ top: event.pageY - iframePosition.top + scrollPosition.top
16999
+ };
17000
+ }
17001
+ return {
17002
+ left: event.pageX,
17003
+ top: event.pageY
17004
+ };
17005
+ };
17006
+ var calculatePosition = function (bodyPosition, scrollPosition, mousePosition) {
17007
+ return {
17008
+ pageX: mousePosition.left - bodyPosition.left + scrollPosition.left,
17009
+ pageY: mousePosition.top - bodyPosition.top + scrollPosition.top
17010
+ };
17011
+ };
17012
+ var calc = function (editor, event) {
17013
+ return calculatePosition(getBodyPosition(editor), getScrollPosition(editor), getMousePosition(editor, event));
17014
+ };
17015
+ var MousePosition = { calc: calc };
17016
+
17017
+ var isContentEditableFalse$8 = NodeType.isContentEditableFalse, isContentEditableTrue$3 = NodeType.isContentEditableTrue;
17018
+ var isDraggable = function (rootElm, elm) {
17019
+ return isContentEditableFalse$8(elm) && elm !== rootElm;
17020
+ };
17021
+ var isValidDropTarget = function (editor, targetElement, dragElement) {
17022
+ if (targetElement === dragElement || editor.dom.isChildOf(targetElement, dragElement)) {
17023
+ return false;
17024
+ }
17025
+ if (isContentEditableFalse$8(targetElement)) {
17026
+ return false;
17027
+ }
17028
+ return true;
17029
+ };
17030
+ var cloneElement = function (elm) {
17031
+ var cloneElm = elm.cloneNode(true);
17032
+ cloneElm.removeAttribute('data-mce-selected');
17033
+ return cloneElm;
17034
+ };
17035
+ var createGhost = function (editor, elm, width, height) {
17036
+ var clonedElm = elm.cloneNode(true);
17037
+ editor.dom.setStyles(clonedElm, {
17038
+ width: width,
17039
+ height: height
17040
+ });
17041
+ editor.dom.setAttrib(clonedElm, 'data-mce-selected', null);
17042
+ var ghostElm = editor.dom.create('div', {
17043
+ 'class': 'mce-drag-container',
17044
+ 'data-mce-bogus': 'all',
17045
+ 'unselectable': 'on',
17046
+ 'contenteditable': 'false'
17047
+ });
17048
+ editor.dom.setStyles(ghostElm, {
17049
+ position: 'absolute',
17050
+ opacity: 0.5,
17051
+ overflow: 'hidden',
17052
+ border: 0,
17053
+ padding: 0,
17054
+ margin: 0,
17055
+ width: width,
17056
+ height: height
17057
+ });
17058
+ editor.dom.setStyles(clonedElm, {
17059
+ margin: 0,
17060
+ boxSizing: 'border-box'
17061
+ });
17062
+ ghostElm.appendChild(clonedElm);
17063
+ return ghostElm;
17064
+ };
17065
+ var appendGhostToBody = function (ghostElm, bodyElm) {
17066
+ if (ghostElm.parentNode !== bodyElm) {
17067
+ bodyElm.appendChild(ghostElm);
17068
+ }
17069
+ };
17070
+ var moveGhost = function (ghostElm, position, width, height, maxX, maxY) {
17071
+ var overflowX = 0, overflowY = 0;
17072
+ ghostElm.style.left = position.pageX + 'px';
17073
+ ghostElm.style.top = position.pageY + 'px';
17074
+ if (position.pageX + width > maxX) {
17075
+ overflowX = position.pageX + width - maxX;
17076
+ }
17077
+ if (position.pageY + height > maxY) {
17078
+ overflowY = position.pageY + height - maxY;
17079
+ }
17080
+ ghostElm.style.width = width - overflowX + 'px';
17081
+ ghostElm.style.height = height - overflowY + 'px';
17082
+ };
17083
+ var removeElement = function (elm) {
17084
+ if (elm && elm.parentNode) {
17085
+ elm.parentNode.removeChild(elm);
17086
+ }
17087
+ };
17088
+ var isLeftMouseButtonPressed = function (e) {
17089
+ return e.button === 0;
17090
+ };
17091
+ var hasDraggableElement = function (state) {
17092
+ return state.element;
17093
+ };
17094
+ var applyRelPos = function (state, position) {
17095
+ return {
17096
+ pageX: position.pageX - state.relX,
17097
+ pageY: position.pageY + 5
17098
+ };
17099
+ };
17100
+ var start$1 = function (state, editor) {
17101
+ return function (e) {
17102
+ if (isLeftMouseButtonPressed(e)) {
17103
+ var ceElm = find(editor.dom.getParents(e.target), Predicate.or(isContentEditableFalse$8, isContentEditableTrue$3)).getOr(null);
17104
+ if (isDraggable(editor.getBody(), ceElm)) {
17105
+ var elmPos = editor.dom.getPos(ceElm);
17106
+ var bodyElm = editor.getBody();
17107
+ var docElm = editor.getDoc().documentElement;
17108
+ state.element = ceElm;
17109
+ state.screenX = e.screenX;
17110
+ state.screenY = e.screenY;
17111
+ state.maxX = (editor.inline ? bodyElm.scrollWidth : docElm.offsetWidth) - 2;
17112
+ state.maxY = (editor.inline ? bodyElm.scrollHeight : docElm.offsetHeight) - 2;
17113
+ state.relX = e.pageX - elmPos.x;
17114
+ state.relY = e.pageY - elmPos.y;
17115
+ state.width = ceElm.offsetWidth;
17116
+ state.height = ceElm.offsetHeight;
17117
+ state.ghost = createGhost(editor, ceElm, state.width, state.height);
17118
+ }
17119
+ }
17120
+ };
17121
+ };
17122
+ var move$1 = function (state, editor) {
17123
+ var throttledPlaceCaretAt = Delay.throttle(function (clientX, clientY) {
17124
+ editor._selectionOverrides.hideFakeCaret();
17125
+ editor.selection.placeCaretAt(clientX, clientY);
17126
+ }, 0);
17127
+ return function (e) {
17128
+ var movement = Math.max(Math.abs(e.screenX - state.screenX), Math.abs(e.screenY - state.screenY));
17129
+ if (hasDraggableElement(state) && !state.dragging && movement > 10) {
17130
+ var args = editor.fire('dragstart', { target: state.element });
17131
+ if (args.isDefaultPrevented()) {
17132
+ return;
17133
+ }
17134
+ state.dragging = true;
17135
+ editor.focus();
17136
+ }
17137
+ if (state.dragging) {
17138
+ var targetPos = applyRelPos(state, MousePosition.calc(editor, e));
17139
+ appendGhostToBody(state.ghost, editor.getBody());
17140
+ moveGhost(state.ghost, targetPos, state.width, state.height, state.maxX, state.maxY);
17141
+ throttledPlaceCaretAt(e.clientX, e.clientY);
17142
+ }
17143
+ };
17144
+ };
17145
+ var getRawTarget = function (selection) {
17146
+ var rng = selection.getSel().getRangeAt(0);
17147
+ var startContainer = rng.startContainer;
17148
+ return startContainer.nodeType === 3 ? startContainer.parentNode : startContainer;
17149
+ };
17150
+ var drop = function (state, editor) {
17151
+ return function (e) {
17152
+ if (state.dragging) {
17153
+ if (isValidDropTarget(editor, getRawTarget(editor.selection), state.element)) {
17154
+ var targetClone_1 = cloneElement(state.element);
17155
+ var args = editor.fire('drop', {
17156
+ targetClone: targetClone_1,
17157
+ clientX: e.clientX,
17158
+ clientY: e.clientY
17159
+ });
17160
+ if (!args.isDefaultPrevented()) {
17161
+ targetClone_1 = args.targetClone;
17162
+ editor.undoManager.transact(function () {
17163
+ removeElement(state.element);
17164
+ editor.insertContent(editor.dom.getOuterHTML(targetClone_1));
17165
+ editor._selectionOverrides.hideFakeCaret();
17166
+ });
17167
+ }
17168
+ }
17169
+ }
17170
+ removeDragState(state);
17171
+ };
17077
17172
  };
17078
- var walkUntil$1 = function (direction, root, predicateFn, node) {
17079
- while (node = findNode$1(node, direction, isEditableCaretCandidate, root)) {
17080
- if (predicateFn(node)) {
17081
- return;
17173
+ var stop = function (state, editor) {
17174
+ return function () {
17175
+ if (state.dragging) {
17176
+ editor.fire('dragend');
17082
17177
  }
17083
- }
17084
- };
17085
- var findLineNodeRects = function (root, targetNodeRect) {
17086
- var clientRects = [];
17087
- var collect = function (checkPosFn, node) {
17088
- var lineRects;
17089
- lineRects = filter(getClientRects([node]), function (clientRect) {
17090
- return !checkPosFn(clientRect, targetNodeRect);
17091
- });
17092
- clientRects = clientRects.concat(lineRects);
17093
- return lineRects.length === 0;
17178
+ removeDragState(state);
17094
17179
  };
17095
- clientRects.push(targetNodeRect);
17096
- walkUntil$1(VDirection.Up, root, curry(collect, isAbove), targetNodeRect.node);
17097
- walkUntil$1(VDirection.Down, root, curry(collect, isBelow), targetNodeRect.node);
17098
- return clientRects;
17099
- };
17100
- var getFakeCaretTargets = function (root) {
17101
- return filter(from$1(root.getElementsByTagName('*')), isFakeCaretTarget);
17102
17180
  };
17103
- var caretInfo = function (clientRect, clientX) {
17104
- return {
17105
- node: clientRect.node,
17106
- before: distanceToRectLeft(clientRect, clientX) < distanceToRectRight(clientRect, clientX)
17107
- };
17181
+ var removeDragState = function (state) {
17182
+ state.dragging = false;
17183
+ state.element = null;
17184
+ removeElement(state.ghost);
17108
17185
  };
17109
- var closestCaret = function (root, clientX, clientY) {
17110
- var closestNodeRect;
17111
- var contentEditableFalseNodeRects = getClientRects(getFakeCaretTargets(root));
17112
- var targetNodeRects = filter(contentEditableFalseNodeRects, function (rect) {
17113
- return clientY >= rect.top && clientY <= rect.bottom;
17186
+ var bindFakeDragEvents = function (editor) {
17187
+ var state = {};
17188
+ var pageDom, dragStartHandler, dragHandler, dropHandler, dragEndHandler, rootDocument;
17189
+ pageDom = DOMUtils$1.DOM;
17190
+ rootDocument = domGlobals.document;
17191
+ dragStartHandler = start$1(state, editor);
17192
+ dragHandler = move$1(state, editor);
17193
+ dropHandler = drop(state, editor);
17194
+ dragEndHandler = stop(state, editor);
17195
+ editor.on('mousedown', dragStartHandler);
17196
+ editor.on('mousemove', dragHandler);
17197
+ editor.on('mouseup', dropHandler);
17198
+ pageDom.bind(rootDocument, 'mousemove', dragHandler);
17199
+ pageDom.bind(rootDocument, 'mouseup', dragEndHandler);
17200
+ editor.on('remove', function () {
17201
+ pageDom.unbind(rootDocument, 'mousemove', dragHandler);
17202
+ pageDom.unbind(rootDocument, 'mouseup', dragEndHandler);
17114
17203
  });
17115
- closestNodeRect = findClosestClientRect(targetNodeRects, clientX);
17116
- if (closestNodeRect) {
17117
- closestNodeRect = findClosestClientRect(findLineNodeRects(root, closestNodeRect), clientX);
17118
- if (closestNodeRect && isFakeCaretTarget(closestNodeRect.node)) {
17119
- return caretInfo(closestNodeRect, clientX);
17120
- }
17121
- }
17122
- return null;
17123
17204
  };
17124
-
17125
- var isXYWithinRange = function (clientX, clientY, range) {
17126
- if (range.collapsed) {
17127
- return false;
17128
- }
17129
- if (Env.ie && Env.ie <= 11 && range.startOffset === range.endOffset - 1 && range.startContainer === range.endContainer) {
17130
- var elm = range.startContainer.childNodes[range.startOffset];
17131
- if (NodeType.isElement(elm)) {
17132
- return exists(elm.getClientRects(), function (rect) {
17133
- return containsXY(rect, clientX, clientY);
17134
- });
17205
+ var blockIeDrop = function (editor) {
17206
+ editor.on('drop', function (e) {
17207
+ var realTarget = typeof e.clientX !== 'undefined' ? editor.getDoc().elementFromPoint(e.clientX, e.clientY) : null;
17208
+ if (isContentEditableFalse$8(realTarget) || isContentEditableFalse$8(editor.dom.getContentEditableParent(realTarget))) {
17209
+ e.preventDefault();
17135
17210
  }
17136
- }
17137
- return exists(range.getClientRects(), function (rect) {
17138
- return containsXY(rect, clientX, clientY);
17139
17211
  });
17140
17212
  };
17141
- var RangePoint = { isXYWithinRange: isXYWithinRange };
17213
+ var init = function (editor) {
17214
+ bindFakeDragEvents(editor);
17215
+ blockIeDrop(editor);
17216
+ };
17217
+ var DragDropOverrides = { init: init };
17142
17218
 
17143
17219
  var setup$4 = function (editor) {
17144
17220
  var renderFocusCaret = first(function () {
@@ -17159,26 +17235,6 @@
17159
17235
  };
17160
17236
  var CefFocus = { setup: setup$4 };
17161
17237
 
17162
- var VK = {
17163
- BACKSPACE: 8,
17164
- DELETE: 46,
17165
- DOWN: 40,
17166
- ENTER: 13,
17167
- LEFT: 37,
17168
- RIGHT: 39,
17169
- SPACEBAR: 32,
17170
- TAB: 9,
17171
- UP: 38,
17172
- END: 35,
17173
- HOME: 36,
17174
- modifierPressed: function (e) {
17175
- return e.shiftKey || e.ctrlKey || e.altKey || this.metaKeyPressed(e);
17176
- },
17177
- metaKeyPressed: function (e) {
17178
- return Env.mac ? e.metaKey : e.ctrlKey && !e.altKey;
17179
- }
17180
- };
17181
-
17182
17238
  var isContentEditableTrue$4 = NodeType.isContentEditableTrue;
17183
17239
  var isContentEditableFalse$9 = NodeType.isContentEditableFalse;
17184
17240
  var getContentEditableRoot$1 = function (editor, node) {
@@ -17377,8 +17433,8 @@
17377
17433
  }
17378
17434
  });
17379
17435
  editor.on('setSelectionRange', function (e) {
17380
- var rng;
17381
- rng = setContentEditableSelection(e.range, e.forward);
17436
+ e.range = normalizeShortEndedElementSelection(e.range);
17437
+ var rng = setContentEditableSelection(e.range, e.forward);
17382
17438
  if (rng) {
17383
17439
  e.range = rng;
17384
17440
  }
@@ -17421,6 +17477,33 @@
17421
17477
  var isRangeInCaretContainer = function (rng) {
17422
17478
  return isWithinCaretContainer(rng.startContainer) || isWithinCaretContainer(rng.endContainer);
17423
17479
  };
17480
+ var normalizeShortEndedElementSelection = function (rng) {
17481
+ var shortEndedElements = editor.schema.getShortEndedElements();
17482
+ var newRng = editor.dom.createRng();
17483
+ var startContainer = rng.startContainer;
17484
+ var startOffset = rng.startOffset;
17485
+ var endContainer = rng.endContainer;
17486
+ var endOffset = rng.endOffset;
17487
+ if (has(shortEndedElements, startContainer.nodeName.toLowerCase())) {
17488
+ if (startOffset === 0) {
17489
+ newRng.setStartBefore(startContainer);
17490
+ } else {
17491
+ newRng.setStartAfter(startContainer);
17492
+ }
17493
+ } else {
17494
+ newRng.setStart(startContainer, startOffset);
17495
+ }
17496
+ if (has(shortEndedElements, endContainer.nodeName.toLowerCase())) {
17497
+ if (endOffset === 0) {
17498
+ newRng.setEndBefore(endContainer);
17499
+ } else {
17500
+ newRng.setEndAfter(endContainer);
17501
+ }
17502
+ } else {
17503
+ newRng.setEnd(endContainer, endOffset);
17504
+ }
17505
+ return newRng;
17506
+ };
17424
17507
  var setContentEditableSelection = function (range, forward) {
17425
17508
  var node;
17426
17509
  var $ = editor.$;
@@ -17541,7 +17624,11 @@
17541
17624
  return name.indexOf('data-') === 0 || name.indexOf('aria-') === 0;
17542
17625
  };
17543
17626
  var trimComments = function (text) {
17544
- return text.replace(/<!--|-->/g, '');
17627
+ var sanitizedText = text;
17628
+ while (/<!--|--!?>/g.test(sanitizedText)) {
17629
+ sanitizedText = sanitizedText.replace(/<!--|--!?>/g, '');
17630
+ }
17631
+ return sanitizedText;
17545
17632
  };
17546
17633
  var isInvalidUri = function (settings, uri) {
17547
17634
  if (settings.allow_html_data_urls) {
@@ -17679,7 +17766,7 @@
17679
17766
  value: value
17680
17767
  });
17681
17768
  };
17682
- tokenRegExp = new RegExp('<(?:' + '(?:!--([\\w\\W]*?)-->)|' + '(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|' + '(?:!DOCTYPE([\\w\\W]*?)>)|' + '(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|' + '(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)|' + '(?:([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)((?:\\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\\/|\\s+)>)' + ')', 'g');
17769
+ tokenRegExp = new RegExp('<(?:' + '(?:!--([\\w\\W]*?)--!?>)|' + '(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|' + '(?:!DOCTYPE([\\w\\W]*?)>)|' + '(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|' + '(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)|' + '(?:([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)((?:\\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\\/|\\s+)>)' + ')', 'g');
17683
17770
  attrRegExp = /([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g;
17684
17771
  shortEndedElements = schema.getShortEndedElements();
17685
17772
  selfClosing = settings.self_closing_elements || schema.getSelfClosingElements();
@@ -20426,7 +20513,7 @@
20426
20513
  var blockElements = Tools.extend({}, schema.getBlockElements());
20427
20514
  var nonEmptyElements = schema.getNonEmptyElements();
20428
20515
  var parent, lastParent, prev, prevName;
20429
- var whiteSpaceElements = schema.getNonEmptyElements();
20516
+ var whiteSpaceElements = schema.getWhiteSpaceElements();
20430
20517
  var elementRule, textNode;
20431
20518
  blockElements.body = 1;
20432
20519
  for (i = 0; i < l; i++) {
@@ -21501,99 +21588,6 @@
21501
21588
  };
21502
21589
  };
21503
21590
 
21504
- var getPos$1 = function (elm) {
21505
- var x = 0, y = 0;
21506
- var offsetParent = elm;
21507
- while (offsetParent && offsetParent.nodeType) {
21508
- x += offsetParent.offsetLeft || 0;
21509
- y += offsetParent.offsetTop || 0;
21510
- offsetParent = offsetParent.offsetParent;
21511
- }
21512
- return {
21513
- x: x,
21514
- y: y
21515
- };
21516
- };
21517
- var fireScrollIntoViewEvent = function (editor, elm, alignToTop) {
21518
- var scrollEvent = {
21519
- elm: elm,
21520
- alignToTop: alignToTop
21521
- };
21522
- editor.fire('scrollIntoView', scrollEvent);
21523
- return scrollEvent.isDefaultPrevented();
21524
- };
21525
- var scrollElementIntoView = function (editor, elm, alignToTop) {
21526
- var y, viewPort;
21527
- var dom = editor.dom;
21528
- var root = dom.getRoot();
21529
- var viewPortY, viewPortH, offsetY = 0;
21530
- if (fireScrollIntoViewEvent(editor, elm, alignToTop)) {
21531
- return;
21532
- }
21533
- if (!NodeType.isElement(elm)) {
21534
- return;
21535
- }
21536
- if (alignToTop === false) {
21537
- offsetY = elm.offsetHeight;
21538
- }
21539
- if (root.nodeName !== 'BODY') {
21540
- var scrollContainer = editor.selection.getScrollContainer();
21541
- if (scrollContainer) {
21542
- y = getPos$1(elm).y - getPos$1(scrollContainer).y + offsetY;
21543
- viewPortH = scrollContainer.clientHeight;
21544
- viewPortY = scrollContainer.scrollTop;
21545
- if (y < viewPortY || y + 25 > viewPortY + viewPortH) {
21546
- scrollContainer.scrollTop = y < viewPortY ? y : y - viewPortH + 25;
21547
- }
21548
- return;
21549
- }
21550
- }
21551
- viewPort = dom.getViewPort(editor.getWin());
21552
- y = dom.getPos(elm).y + offsetY;
21553
- viewPortY = viewPort.y;
21554
- viewPortH = viewPort.h;
21555
- if (y < viewPort.y || y + 25 > viewPortY + viewPortH) {
21556
- editor.getWin().scrollTo(0, y < viewPortY ? y : y - viewPortH + 25);
21557
- }
21558
- };
21559
- var getViewPortRect = function (editor) {
21560
- if (editor.inline) {
21561
- return editor.getBody().getBoundingClientRect();
21562
- } else {
21563
- var win = editor.getWin();
21564
- return {
21565
- left: 0,
21566
- right: win.innerWidth,
21567
- top: 0,
21568
- bottom: win.innerHeight,
21569
- width: win.innerWidth,
21570
- height: win.innerHeight
21571
- };
21572
- }
21573
- };
21574
- var scrollBy = function (editor, dx, dy) {
21575
- if (editor.inline) {
21576
- editor.getBody().scrollLeft += dx;
21577
- editor.getBody().scrollTop += dy;
21578
- } else {
21579
- editor.getWin().scrollBy(dx, dy);
21580
- }
21581
- };
21582
- var scrollRangeIntoView = function (editor, rng) {
21583
- head(CaretPosition.fromRangeStart(rng).getClientRects()).each(function (rngRect) {
21584
- var bodyRect = getViewPortRect(editor);
21585
- var overflow = getOverflow(bodyRect, rngRect);
21586
- var margin = 4;
21587
- var dx = overflow.x > 0 ? overflow.x + margin : overflow.x - margin;
21588
- var dy = overflow.y > 0 ? overflow.y + margin : overflow.y - margin;
21589
- scrollBy(editor, overflow.x !== 0 ? dx : 0, overflow.y !== 0 ? dy : 0);
21590
- });
21591
- };
21592
- var ScrollIntoView = {
21593
- scrollElementIntoView: scrollElementIntoView,
21594
- scrollRangeIntoView: scrollRangeIntoView
21595
- };
21596
-
21597
21591
  var hasCeProperty = function (node) {
21598
21592
  return NodeType.isContentEditableTrue(node) || NodeType.isContentEditableFalse(node);
21599
21593
  };
@@ -21912,22 +21906,37 @@
21912
21906
  };
21913
21907
  var GetSelectionContent = { getContent: getContent };
21914
21908
 
21909
+ var setupArgs = function (args, content) {
21910
+ return __assign(__assign({ format: 'html' }, args), {
21911
+ set: true,
21912
+ selection: true,
21913
+ content: content
21914
+ });
21915
+ };
21916
+ var cleanContent = function (editor, args) {
21917
+ if (args.format !== 'raw') {
21918
+ var node = editor.parser.parse(args.content, __assign({
21919
+ isRootContent: true,
21920
+ forced_root_block: false
21921
+ }, args));
21922
+ return HtmlSerializer({ validate: editor.validate }, editor.schema).serialize(node);
21923
+ } else {
21924
+ return args.content;
21925
+ }
21926
+ };
21915
21927
  var setContent = function (editor, content, args) {
21928
+ var contentArgs = setupArgs(args, content);
21916
21929
  var rng = editor.selection.getRng(), caretNode;
21917
21930
  var doc = editor.getDoc();
21918
21931
  var frag, temp;
21919
- args = args || { format: 'html' };
21920
- args.set = true;
21921
- args.selection = true;
21922
- args.content = content;
21923
- if (!args.no_events) {
21924
- args = editor.fire('BeforeSetContent', args);
21925
- if (args.isDefaultPrevented()) {
21926
- editor.fire('SetContent', args);
21932
+ if (!contentArgs.no_events) {
21933
+ contentArgs = editor.fire('BeforeSetContent', contentArgs);
21934
+ if (contentArgs.isDefaultPrevented()) {
21935
+ editor.fire('SetContent', contentArgs);
21927
21936
  return;
21928
21937
  }
21929
21938
  }
21930
- content = args.content;
21939
+ content = cleanContent(editor, contentArgs);
21931
21940
  if (rng.insertNode) {
21932
21941
  content += '<span id="__caret">_</span>';
21933
21942
  if (rng.startContainer === doc && rng.endContainer === doc) {
@@ -21959,19 +21968,20 @@
21959
21968
  } catch (ex) {
21960
21969
  }
21961
21970
  } else {
21962
- if (rng.item) {
21971
+ var anyRng = rng;
21972
+ if (anyRng.item) {
21963
21973
  doc.execCommand('Delete', false, null);
21964
- rng = editor.getRng();
21974
+ anyRng = editor.selection.getRng();
21965
21975
  }
21966
21976
  if (/^\s+/.test(content)) {
21967
- rng.pasteHTML('<span id="__mce_tmp">_</span>' + content);
21977
+ anyRng.pasteHTML('<span id="__mce_tmp">_</span>' + content);
21968
21978
  editor.dom.remove('__mce_tmp');
21969
21979
  } else {
21970
- rng.pasteHTML(content);
21980
+ anyRng.pasteHTML(content);
21971
21981
  }
21972
21982
  }
21973
- if (!args.no_events) {
21974
- editor.fire('SetContent', args);
21983
+ if (!contentArgs.no_events) {
21984
+ editor.fire('SetContent', contentArgs);
21975
21985
  }
21976
21986
  };
21977
21987
  var SetSelectionContent = { setContent: setContent };
@@ -22479,10 +22489,7 @@
22479
22489
  return acc.fold(function () {
22480
22490
  return Option.some(newPos);
22481
22491
  }, function (lastPos) {
22482
- return liftN([
22483
- head(lastPos.getClientRects()),
22484
- head(newPos.getClientRects())
22485
- ], function (lastRect, newRect) {
22492
+ return lift2(head(lastPos.getClientRects()), head(newPos.getClientRects()), function (lastRect, newRect) {
22486
22493
  var lastDist = Math.abs(x - lastRect.left);
22487
22494
  var newDist = Math.abs(x - newRect.left);
22488
22495
  return newDist <= lastDist ? newPos : lastPos;
@@ -22663,7 +22670,7 @@
22663
22670
  return function () {
22664
22671
  var newRng = getHorizontalRange(editor, forward);
22665
22672
  if (newRng) {
22666
- editor.selection.setRng(newRng);
22673
+ moveToRange(editor, newRng);
22667
22674
  return true;
22668
22675
  } else {
22669
22676
  return false;
@@ -22674,7 +22681,7 @@
22674
22681
  return function () {
22675
22682
  var newRng = getVerticalRange(editor, down);
22676
22683
  if (newRng) {
22677
- editor.selection.setRng(newRng);
22684
+ moveToRange(editor, newRng);
22678
22685
  return true;
22679
22686
  } else {
22680
22687
  return false;
@@ -22776,10 +22783,6 @@
22776
22783
  });
22777
22784
  };
22778
22785
 
22779
- var moveToRange = function (editor, rng) {
22780
- editor.selection.setRng(rng);
22781
- ScrollIntoView.scrollRangeIntoView(editor, rng);
22782
- };
22783
22786
  var hasNextBreak = function (getPositionsUntil, scope, lineInfo) {
22784
22787
  return lineInfo.breakAt.map(function (breakPos) {
22785
22788
  return getPositionsUntil(scope, breakPos).breakAt.isSome();
@@ -23430,10 +23433,41 @@
23430
23433
  }
23431
23434
  return parent !== root ? editableRoot : root;
23432
23435
  };
23436
+ var applyAttributes = function (editor, node, forcedRootBlockAttrs) {
23437
+ Option.from(forcedRootBlockAttrs.style).map(editor.dom.parseStyle).each(function (attrStyles) {
23438
+ var currentStyles = getAllRaw(Element.fromDom(node));
23439
+ var newStyles = __assign(__assign({}, currentStyles), attrStyles);
23440
+ editor.dom.setStyles(node, newStyles);
23441
+ });
23442
+ var attrClassesOpt = Option.from(forcedRootBlockAttrs.class).map(function (attrClasses) {
23443
+ return attrClasses.split(/\s+/);
23444
+ });
23445
+ var currentClassesOpt = Option.from(node.className).map(function (currentClasses) {
23446
+ return filter(currentClasses.split(/\s+/), function (clazz) {
23447
+ return clazz !== '';
23448
+ });
23449
+ });
23450
+ lift2(attrClassesOpt, currentClassesOpt, function (attrClasses, currentClasses) {
23451
+ var filteredClasses = filter(currentClasses, function (clazz) {
23452
+ return !contains(attrClasses, clazz);
23453
+ });
23454
+ var newClasses = __spreadArrays(attrClasses, filteredClasses);
23455
+ editor.dom.setAttrib(node, 'class', newClasses.join(' '));
23456
+ });
23457
+ var appliedAttrs = [
23458
+ 'style',
23459
+ 'class'
23460
+ ];
23461
+ var remainingAttrs = bifilter(forcedRootBlockAttrs, function (_, attrs) {
23462
+ return !contains(appliedAttrs, attrs);
23463
+ }).t;
23464
+ editor.dom.setAttribs(node, remainingAttrs);
23465
+ };
23433
23466
  var setForcedBlockAttrs = function (editor, node) {
23434
23467
  var forcedRootBlockName = Settings.getForcedRootBlock(editor);
23435
23468
  if (forcedRootBlockName && forcedRootBlockName.toLowerCase() === node.tagName.toLowerCase()) {
23436
- editor.dom.setAttribs(node, Settings.getForcedRootBlockAttrs(editor));
23469
+ var forcedRootBlockAttrs = Settings.getForcedRootBlockAttrs(editor);
23470
+ applyAttributes(editor, node, forcedRootBlockAttrs);
23437
23471
  }
23438
23472
  };
23439
23473
  var wrapSelfAndSiblingsInDefaultBlock = function (editor, newBlockName, rng, container, offset) {
@@ -23499,7 +23533,6 @@
23499
23533
  var textInlineElements = schema.getTextInlineElements();
23500
23534
  if (name || parentBlockName === 'TABLE' || parentBlockName === 'HR') {
23501
23535
  block = dom.create(name || newBlockName);
23502
- setForcedBlockAttrs(editor, block);
23503
23536
  } else {
23504
23537
  block = parentBlock.cloneNode(false);
23505
23538
  }
@@ -23525,6 +23558,7 @@
23525
23558
  }
23526
23559
  } while ((node = node.parentNode) && node !== editableRoot);
23527
23560
  }
23561
+ setForcedBlockAttrs(editor, block);
23528
23562
  emptyBlock(caretNode);
23529
23563
  return block;
23530
23564
  };
@@ -23631,6 +23665,7 @@
23631
23665
  if (dom.isEmpty(parentBlock)) {
23632
23666
  emptyBlock(parentBlock);
23633
23667
  }
23668
+ setForcedBlockAttrs(editor, newBlock);
23634
23669
  NewLineUtils.moveToCaretPosition(editor, newBlock);
23635
23670
  } else if (isCaretAtStartOrEndOfBlock()) {
23636
23671
  insertNewBlockAfter();
@@ -23655,6 +23690,7 @@
23655
23690
  dom.remove(newBlock);
23656
23691
  insertNewBlockAfter();
23657
23692
  } else {
23693
+ setForcedBlockAttrs(editor, newBlock);
23658
23694
  NewLineUtils.moveToCaretPosition(editor, newBlock);
23659
23695
  }
23660
23696
  }
@@ -23953,7 +23989,8 @@
23953
23989
  return NodeType.isText(container) && contains$2(container.data, nbsp);
23954
23990
  };
23955
23991
  var normalizeNbspMiddle = function (text) {
23956
- return map(text.split(''), function (chr, i, chars) {
23992
+ var chars = text.split('');
23993
+ return map(chars, function (chr, i) {
23957
23994
  if (isNbsp(chr) && i > 0 && i < chars.length - 1 && isContent$1(chars[i - 1]) && isContent$1(chars[i + 1])) {
23958
23995
  return ' ';
23959
23996
  } else {
@@ -26344,15 +26381,15 @@
26344
26381
  defaultSettings: {},
26345
26382
  $: DomQuery,
26346
26383
  majorVersion: '4',
26347
- minorVersion: '9.6',
26348
- releaseDate: '2019-09-02',
26384
+ minorVersion: '9.11',
26385
+ releaseDate: '2020-07-13',
26349
26386
  editors: legacyEditors,
26350
26387
  i18n: I18n,
26351
26388
  activeEditor: null,
26352
26389
  settings: {},
26353
26390
  setup: function () {
26354
26391
  var self = this;
26355
- var baseURL, documentBaseURL, suffix = '', preInit, src;
26392
+ var baseURL, documentBaseURL, suffix = '';
26356
26393
  documentBaseURL = URI.getDocumentBaseUrl(domGlobals.document.location);
26357
26394
  if (/^[^:]+:\/\/\/?[^\/]+\//.test(documentBaseURL)) {
26358
26395
  documentBaseURL = documentBaseURL.replace(/[\?#].*$/, '').replace(/[\/\\][^\/]+$/, '');
@@ -26360,14 +26397,17 @@
26360
26397
  documentBaseURL += '/';
26361
26398
  }
26362
26399
  }
26363
- preInit = window.tinymce || window.tinyMCEPreInit;
26400
+ var preInit = window.tinymce || window.tinyMCEPreInit;
26364
26401
  if (preInit) {
26365
26402
  baseURL = preInit.base || preInit.baseURL;
26366
26403
  suffix = preInit.suffix;
26367
26404
  } else {
26368
26405
  var scripts = domGlobals.document.getElementsByTagName('script');
26369
26406
  for (var i = 0; i < scripts.length; i++) {
26370
- src = scripts[i].src;
26407
+ var src = scripts[i].src || '';
26408
+ if (src === '') {
26409
+ continue;
26410
+ }
26371
26411
  var srcScript = src.substring(src.lastIndexOf('/'));
26372
26412
  if (/tinymce(\.full|\.jquery|)(\.min|\.dev|)\.js/.test(src)) {
26373
26413
  if (srcScript.indexOf('.min') !== -1) {
@@ -26378,7 +26418,7 @@
26378
26418
  }
26379
26419
  }
26380
26420
  if (!baseURL && domGlobals.document.currentScript) {
26381
- src = domGlobals.document.currentScript.src;
26421
+ var src = domGlobals.document.currentScript.src;
26382
26422
  if (src.indexOf('.min') !== -1) {
26383
26423
  suffix = '.min';
26384
26424
  }