@dangl/angular-material-shared 2.5.1-beta0012 → 2.5.1-beta0018

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +1 -7
  2. package/esm2022/lib/angular-material-shared.module.mjs +2 -2
  3. package/esm2022/lib/components/tiny-mce/tiny-mce.component.mjs +16 -19
  4. package/fesm2022/dangl-angular-material-shared.mjs +16 -19
  5. package/fesm2022/dangl-angular-material-shared.mjs.map +1 -1
  6. package/lib/components/tiny-mce/tiny-mce.component.d.ts +7 -8
  7. package/package.json +1 -1
  8. package/tinymce-assets/icons/default/icons.js +187 -171
  9. package/tinymce-assets/icons/default/icons.min.js +1 -1
  10. package/tinymce-assets/langs/it.js +1 -1
  11. package/tinymce-assets/plugins/accordion/index.js +7 -0
  12. package/tinymce-assets/plugins/accordion/plugin.js +1054 -0
  13. package/tinymce-assets/plugins/accordion/plugin.min.js +4 -0
  14. package/tinymce-assets/plugins/advlist/plugin.js +185 -187
  15. package/tinymce-assets/plugins/advlist/plugin.min.js +2 -7
  16. package/tinymce-assets/plugins/anchor/plugin.js +79 -81
  17. package/tinymce-assets/plugins/anchor/plugin.min.js +2 -7
  18. package/tinymce-assets/plugins/autolink/plugin.js +209 -194
  19. package/tinymce-assets/plugins/autolink/plugin.min.js +2 -7
  20. package/tinymce-assets/plugins/autoresize/plugin.js +110 -102
  21. package/tinymce-assets/plugins/autoresize/plugin.min.js +2 -7
  22. package/tinymce-assets/plugins/autosave/plugin.js +125 -104
  23. package/tinymce-assets/plugins/autosave/plugin.min.js +2 -7
  24. package/tinymce-assets/plugins/charmap/plugin.js +275 -313
  25. package/tinymce-assets/plugins/charmap/plugin.min.js +2 -7
  26. package/tinymce-assets/plugins/code/plugin.js +18 -24
  27. package/tinymce-assets/plugins/code/plugin.min.js +2 -7
  28. package/tinymce-assets/plugins/codesample/plugin.js +2075 -2074
  29. package/tinymce-assets/plugins/codesample/plugin.min.js +2 -7
  30. package/tinymce-assets/plugins/directionality/plugin.js +247 -305
  31. package/tinymce-assets/plugins/directionality/plugin.min.js +2 -7
  32. package/tinymce-assets/plugins/emoticons/js/emojiimages.js +1 -9424
  33. package/tinymce-assets/plugins/emoticons/js/emojiimages.min.js +1 -1
  34. package/tinymce-assets/plugins/emoticons/js/emojis.js +1 -9423
  35. package/tinymce-assets/plugins/emoticons/js/emojis.min.js +1 -1
  36. package/tinymce-assets/plugins/emoticons/plugin.js +334 -374
  37. package/tinymce-assets/plugins/emoticons/plugin.min.js +2 -7
  38. package/tinymce-assets/plugins/fullscreen/plugin.js +740 -837
  39. package/tinymce-assets/plugins/fullscreen/plugin.min.js +2 -7
  40. package/tinymce-assets/plugins/help/js/i18n/keynav/ar.js +90 -0
  41. package/tinymce-assets/plugins/help/js/i18n/keynav/bg_BG.js +90 -0
  42. package/tinymce-assets/plugins/help/js/i18n/keynav/ca.js +90 -0
  43. package/tinymce-assets/plugins/help/js/i18n/keynav/cs.js +90 -0
  44. package/tinymce-assets/plugins/help/js/i18n/keynav/da.js +90 -0
  45. package/tinymce-assets/plugins/help/js/i18n/keynav/de.js +90 -0
  46. package/tinymce-assets/plugins/help/js/i18n/keynav/el.js +90 -0
  47. package/tinymce-assets/plugins/help/js/i18n/keynav/en.js +90 -0
  48. package/tinymce-assets/plugins/help/js/i18n/keynav/es.js +90 -0
  49. package/tinymce-assets/plugins/help/js/i18n/keynav/eu.js +90 -0
  50. package/tinymce-assets/plugins/help/js/i18n/keynav/fa.js +90 -0
  51. package/tinymce-assets/plugins/help/js/i18n/keynav/fi.js +90 -0
  52. package/tinymce-assets/plugins/help/js/i18n/keynav/fr_FR.js +90 -0
  53. package/tinymce-assets/plugins/help/js/i18n/keynav/he_IL.js +90 -0
  54. package/tinymce-assets/plugins/help/js/i18n/keynav/hi.js +90 -0
  55. package/tinymce-assets/plugins/help/js/i18n/keynav/hr.js +90 -0
  56. package/tinymce-assets/plugins/help/js/i18n/keynav/hu_HU.js +90 -0
  57. package/tinymce-assets/plugins/help/js/i18n/keynav/id.js +90 -0
  58. package/tinymce-assets/plugins/help/js/i18n/keynav/it.js +90 -0
  59. package/tinymce-assets/plugins/help/js/i18n/keynav/ja.js +90 -0
  60. package/tinymce-assets/plugins/help/js/i18n/keynav/kk.js +90 -0
  61. package/tinymce-assets/plugins/help/js/i18n/keynav/ko_KR.js +90 -0
  62. package/tinymce-assets/plugins/help/js/i18n/keynav/ms.js +90 -0
  63. package/tinymce-assets/plugins/help/js/i18n/keynav/nb_NO.js +90 -0
  64. package/tinymce-assets/plugins/help/js/i18n/keynav/nl.js +90 -0
  65. package/tinymce-assets/plugins/help/js/i18n/keynav/pl.js +90 -0
  66. package/tinymce-assets/plugins/help/js/i18n/keynav/pt_BR.js +90 -0
  67. package/tinymce-assets/plugins/help/js/i18n/keynav/pt_PT.js +90 -0
  68. package/tinymce-assets/plugins/help/js/i18n/keynav/ro.js +90 -0
  69. package/tinymce-assets/plugins/help/js/i18n/keynav/ru.js +90 -0
  70. package/tinymce-assets/plugins/help/js/i18n/keynav/sk.js +90 -0
  71. package/tinymce-assets/plugins/help/js/i18n/keynav/sl_SI.js +90 -0
  72. package/tinymce-assets/plugins/help/js/i18n/keynav/sv_SE.js +90 -0
  73. package/tinymce-assets/plugins/help/js/i18n/keynav/th_TH.js +90 -0
  74. package/tinymce-assets/plugins/help/js/i18n/keynav/tr.js +90 -0
  75. package/tinymce-assets/plugins/help/js/i18n/keynav/uk.js +90 -0
  76. package/tinymce-assets/plugins/help/js/i18n/keynav/vi.js +90 -0
  77. package/tinymce-assets/plugins/help/js/i18n/keynav/zh_CN.js +84 -0
  78. package/tinymce-assets/plugins/help/js/i18n/keynav/zh_TW.js +90 -0
  79. package/tinymce-assets/plugins/help/plugin.js +411 -355
  80. package/tinymce-assets/plugins/help/plugin.min.js +2 -7
  81. package/tinymce-assets/plugins/image/plugin.js +876 -1037
  82. package/tinymce-assets/plugins/image/plugin.min.js +2 -7
  83. package/tinymce-assets/plugins/importcss/plugin.js +146 -144
  84. package/tinymce-assets/plugins/importcss/plugin.min.js +2 -7
  85. package/tinymce-assets/plugins/insertdatetime/plugin.js +93 -88
  86. package/tinymce-assets/plugins/insertdatetime/plugin.min.js +2 -7
  87. package/tinymce-assets/plugins/link/plugin.js +718 -768
  88. package/tinymce-assets/plugins/link/plugin.min.js +2 -7
  89. package/tinymce-assets/plugins/lists/plugin.js +1235 -1375
  90. package/tinymce-assets/plugins/lists/plugin.min.js +2 -7
  91. package/tinymce-assets/plugins/media/plugin.js +614 -756
  92. package/tinymce-assets/plugins/media/plugin.min.js +2 -7
  93. package/tinymce-assets/plugins/nonbreaking/plugin.js +71 -48
  94. package/tinymce-assets/plugins/nonbreaking/plugin.min.js +2 -7
  95. package/tinymce-assets/plugins/pagebreak/plugin.js +53 -40
  96. package/tinymce-assets/plugins/pagebreak/plugin.min.js +2 -7
  97. package/tinymce-assets/plugins/preview/plugin.js +36 -65
  98. package/tinymce-assets/plugins/preview/plugin.min.js +2 -7
  99. package/tinymce-assets/plugins/quickbars/plugin.js +304 -331
  100. package/tinymce-assets/plugins/quickbars/plugin.min.js +2 -7
  101. package/tinymce-assets/plugins/save/plugin.js +49 -50
  102. package/tinymce-assets/plugins/save/plugin.min.js +2 -7
  103. package/tinymce-assets/plugins/searchreplace/plugin.js +499 -571
  104. package/tinymce-assets/plugins/searchreplace/plugin.min.js +2 -7
  105. package/tinymce-assets/plugins/table/plugin.js +2572 -10617
  106. package/tinymce-assets/plugins/table/plugin.min.js +2 -7
  107. package/tinymce-assets/plugins/visualblocks/plugin.js +41 -46
  108. package/tinymce-assets/plugins/visualblocks/plugin.min.js +2 -7
  109. package/tinymce-assets/plugins/visualchars/plugin.js +346 -312
  110. package/tinymce-assets/plugins/visualchars/plugin.min.js +2 -7
  111. package/tinymce-assets/plugins/wordcount/plugin.js +159 -179
  112. package/tinymce-assets/plugins/wordcount/plugin.min.js +2 -7
  113. package/tinymce-assets/skins/content/dark/content.css +2 -8
  114. package/tinymce-assets/skins/content/dark/content.js +2 -0
  115. package/tinymce-assets/skins/content/dark/content.min.css +1 -7
  116. package/tinymce-assets/skins/content/default/content.css +0 -6
  117. package/tinymce-assets/skins/content/default/content.js +2 -0
  118. package/tinymce-assets/skins/content/default/content.min.css +0 -6
  119. package/tinymce-assets/skins/content/document/content.css +0 -6
  120. package/tinymce-assets/skins/content/document/content.js +2 -0
  121. package/tinymce-assets/skins/content/document/content.min.css +0 -6
  122. package/tinymce-assets/skins/content/tinymce-5/content.css +61 -0
  123. package/tinymce-assets/skins/content/tinymce-5/content.js +2 -0
  124. package/tinymce-assets/skins/content/tinymce-5/content.min.css +1 -0
  125. package/tinymce-assets/skins/content/tinymce-5-dark/content.css +66 -0
  126. package/tinymce-assets/skins/content/tinymce-5-dark/content.js +2 -0
  127. package/tinymce-assets/skins/content/tinymce-5-dark/content.min.css +1 -0
  128. package/tinymce-assets/skins/content/writer/content.css +0 -6
  129. package/tinymce-assets/skins/content/writer/content.js +2 -0
  130. package/tinymce-assets/skins/content/writer/content.min.css +0 -6
  131. package/tinymce-assets/skins/ui/oxide/content.css +73 -20
  132. package/tinymce-assets/skins/ui/oxide/content.inline.css +73 -20
  133. package/tinymce-assets/skins/ui/oxide/content.inline.js +2 -0
  134. package/tinymce-assets/skins/ui/oxide/content.inline.min.css +1 -7
  135. package/tinymce-assets/skins/ui/oxide/content.js +2 -0
  136. package/tinymce-assets/skins/ui/oxide/content.min.css +1 -7
  137. package/tinymce-assets/skins/ui/oxide/skin.css +1480 -435
  138. package/tinymce-assets/skins/ui/oxide/skin.js +2 -0
  139. package/tinymce-assets/skins/ui/oxide/skin.min.css +1 -7
  140. package/tinymce-assets/skins/ui/oxide/skin.shadowdom.css +1 -8
  141. package/tinymce-assets/skins/ui/oxide/skin.shadowdom.js +2 -0
  142. package/tinymce-assets/skins/ui/oxide/skin.shadowdom.min.css +1 -7
  143. package/tinymce-assets/skins/ui/oxide-dark/content.css +71 -19
  144. package/tinymce-assets/skins/ui/oxide-dark/content.inline.css +73 -20
  145. package/tinymce-assets/skins/ui/oxide-dark/content.inline.js +2 -0
  146. package/tinymce-assets/skins/ui/oxide-dark/content.inline.min.css +1 -7
  147. package/tinymce-assets/skins/ui/oxide-dark/content.js +2 -0
  148. package/tinymce-assets/skins/ui/oxide-dark/content.min.css +1 -7
  149. package/tinymce-assets/skins/ui/oxide-dark/skin.css +1498 -450
  150. package/tinymce-assets/skins/ui/oxide-dark/skin.js +2 -0
  151. package/tinymce-assets/skins/ui/oxide-dark/skin.min.css +1 -7
  152. package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.css +1 -8
  153. package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.js +2 -0
  154. package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.min.css +1 -7
  155. package/tinymce-assets/skins/ui/tinymce-5/content.css +785 -0
  156. package/tinymce-assets/skins/ui/tinymce-5/content.inline.css +779 -0
  157. package/tinymce-assets/skins/ui/tinymce-5/content.inline.js +2 -0
  158. package/tinymce-assets/skins/ui/tinymce-5/content.inline.min.css +1 -0
  159. package/tinymce-assets/skins/ui/tinymce-5/content.js +2 -0
  160. package/tinymce-assets/skins/ui/tinymce-5/content.min.css +1 -0
  161. package/tinymce-assets/skins/ui/tinymce-5/skin.css +4185 -0
  162. package/tinymce-assets/skins/ui/tinymce-5/skin.js +2 -0
  163. package/tinymce-assets/skins/ui/tinymce-5/skin.min.css +1 -0
  164. package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.css +30 -0
  165. package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.js +2 -0
  166. package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.min.css +1 -0
  167. package/tinymce-assets/skins/ui/tinymce-5-dark/content.css +766 -0
  168. package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.css +779 -0
  169. package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.js +2 -0
  170. package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.min.css +1 -0
  171. package/tinymce-assets/skins/ui/tinymce-5-dark/content.js +2 -0
  172. package/tinymce-assets/skins/ui/tinymce-5-dark/content.min.css +1 -0
  173. package/tinymce-assets/skins/ui/tinymce-5-dark/skin.css +4185 -0
  174. package/tinymce-assets/skins/ui/tinymce-5-dark/skin.js +2 -0
  175. package/tinymce-assets/skins/ui/tinymce-5-dark/skin.min.css +1 -0
  176. package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.css +30 -0
  177. package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.js +2 -0
  178. package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +1 -0
  179. package/tinymce-assets/themes/silver/theme.js +25226 -28188
  180. package/tinymce-assets/themes/silver/theme.min.js +2 -7
  181. package/tinymce-assets/plugins/bbcode/index.js +0 -7
  182. package/tinymce-assets/plugins/bbcode/plugin.js +0 -99
  183. package/tinymce-assets/plugins/bbcode/plugin.min.js +0 -9
  184. package/tinymce-assets/plugins/colorpicker/index.js +0 -7
  185. package/tinymce-assets/plugins/colorpicker/plugin.js +0 -21
  186. package/tinymce-assets/plugins/colorpicker/plugin.min.js +0 -9
  187. package/tinymce-assets/plugins/contextmenu/index.js +0 -7
  188. package/tinymce-assets/plugins/contextmenu/plugin.js +0 -21
  189. package/tinymce-assets/plugins/contextmenu/plugin.min.js +0 -9
  190. package/tinymce-assets/plugins/fullpage/index.js +0 -7
  191. package/tinymce-assets/plugins/fullpage/plugin.js +0 -544
  192. package/tinymce-assets/plugins/fullpage/plugin.min.js +0 -9
  193. package/tinymce-assets/plugins/hr/index.js +0 -7
  194. package/tinymce-assets/plugins/hr/plugin.js +0 -45
  195. package/tinymce-assets/plugins/hr/plugin.min.js +0 -9
  196. package/tinymce-assets/plugins/imagetools/index.js +0 -7
  197. package/tinymce-assets/plugins/imagetools/plugin.js +0 -1531
  198. package/tinymce-assets/plugins/imagetools/plugin.min.js +0 -9
  199. package/tinymce-assets/plugins/legacyoutput/index.js +0 -7
  200. package/tinymce-assets/plugins/legacyoutput/plugin.js +0 -199
  201. package/tinymce-assets/plugins/legacyoutput/plugin.min.js +0 -9
  202. package/tinymce-assets/plugins/noneditable/index.js +0 -7
  203. package/tinymce-assets/plugins/noneditable/plugin.js +0 -117
  204. package/tinymce-assets/plugins/noneditable/plugin.min.js +0 -9
  205. package/tinymce-assets/plugins/paste/index.js +0 -7
  206. package/tinymce-assets/plugins/paste/plugin.js +0 -1803
  207. package/tinymce-assets/plugins/paste/plugin.min.js +0 -9
  208. package/tinymce-assets/plugins/print/index.js +0 -7
  209. package/tinymce-assets/plugins/print/plugin.js +0 -52
  210. package/tinymce-assets/plugins/print/plugin.min.js +0 -9
  211. package/tinymce-assets/plugins/spellchecker/index.js +0 -7
  212. package/tinymce-assets/plugins/spellchecker/plugin.js +0 -730
  213. package/tinymce-assets/plugins/spellchecker/plugin.min.js +0 -9
  214. package/tinymce-assets/plugins/tabfocus/index.js +0 -7
  215. package/tinymce-assets/plugins/tabfocus/plugin.js +0 -130
  216. package/tinymce-assets/plugins/tabfocus/plugin.min.js +0 -9
  217. package/tinymce-assets/plugins/template/index.js +0 -7
  218. package/tinymce-assets/plugins/template/plugin.js +0 -591
  219. package/tinymce-assets/plugins/template/plugin.min.js +0 -9
  220. package/tinymce-assets/plugins/textcolor/index.js +0 -7
  221. package/tinymce-assets/plugins/textcolor/plugin.js +0 -21
  222. package/tinymce-assets/plugins/textcolor/plugin.min.js +0 -9
  223. package/tinymce-assets/plugins/textpattern/index.js +0 -7
  224. package/tinymce-assets/plugins/textpattern/plugin.js +0 -1374
  225. package/tinymce-assets/plugins/textpattern/plugin.min.js +0 -9
  226. package/tinymce-assets/plugins/toc/index.js +0 -7
  227. package/tinymce-assets/plugins/toc/plugin.js +0 -238
  228. package/tinymce-assets/plugins/toc/plugin.min.js +0 -9
  229. package/tinymce-assets/skins/ui/oxide/content.mobile.css +0 -29
  230. package/tinymce-assets/skins/ui/oxide/content.mobile.min.css +0 -7
  231. package/tinymce-assets/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
  232. package/tinymce-assets/skins/ui/oxide/skin.mobile.css +0 -673
  233. package/tinymce-assets/skins/ui/oxide/skin.mobile.min.css +0 -7
  234. package/tinymce-assets/skins/ui/oxide-dark/content.mobile.css +0 -29
  235. package/tinymce-assets/skins/ui/oxide-dark/content.mobile.min.css +0 -7
  236. package/tinymce-assets/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
  237. package/tinymce-assets/skins/ui/oxide-dark/skin.mobile.css +0 -673
  238. package/tinymce-assets/skins/ui/oxide-dark/skin.mobile.min.css +0 -7
  239. package/tinymce-assets/themes/mobile/index.js +0 -7
  240. package/tinymce-assets/themes/mobile/theme.js +0 -13130
  241. package/tinymce-assets/themes/mobile/theme.min.js +0 -9
@@ -1,168 +1,142 @@
1
1
  /**
2
- * Copyright (c) Tiny Technologies, Inc. All rights reserved.
3
- * Licensed under the LGPL or a commercial license.
4
- * For LGPL see License.txt in the project root for license information.
5
- * For commercial licenses see https://www.tiny.cloud/
6
- *
7
- * Version: 5.10.9 (2023-11-15)
2
+ * TinyMCE version 7.0.1 (2024-04-10)
8
3
  */
4
+
9
5
  (function () {
10
6
  'use strict';
11
7
 
12
- var global$9 = tinymce.util.Tools.resolve('tinymce.PluginManager');
8
+ var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
13
9
 
14
- var __assign = function () {
15
- __assign = Object.assign || function __assign(t) {
16
- for (var s, i = 1, n = arguments.length; i < n; i++) {
17
- s = arguments[i];
18
- for (var p in s)
19
- if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
10
+ const hasProto = (v, constructor, predicate) => {
11
+ var _a;
12
+ if (predicate(v, constructor.prototype)) {
13
+ return true;
14
+ } else {
15
+ return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
16
+ }
25
17
  };
26
-
27
- var typeOf = function (x) {
28
- var t = typeof x;
18
+ const typeOf = x => {
19
+ const t = typeof x;
29
20
  if (x === null) {
30
21
  return 'null';
31
- } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
22
+ } else if (t === 'object' && Array.isArray(x)) {
32
23
  return 'array';
33
- } else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
24
+ } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
34
25
  return 'string';
35
26
  } else {
36
27
  return t;
37
28
  }
38
29
  };
39
- var isType = function (type) {
40
- return function (value) {
41
- return typeOf(value) === type;
42
- };
43
- };
44
- var isString = isType('string');
45
- var isObject = isType('object');
46
- var isArray = isType('array');
47
- var isNullable = function (a) {
48
- return a === null || a === undefined;
49
- };
50
- var isNonNullable = function (a) {
51
- return !isNullable(a);
52
- };
53
-
54
- var noop = function () {
55
- };
56
- var constant = function (value) {
57
- return function () {
58
- return value;
59
- };
60
- };
61
- var identity = function (x) {
62
- return x;
63
- };
64
- var never = constant(false);
65
- var always = constant(true);
30
+ const isType = type => value => typeOf(value) === type;
31
+ const isString = isType('string');
32
+ const isObject = isType('object');
33
+ const isArray = isType('array');
34
+ const isNullable = a => a === null || a === undefined;
35
+ const isNonNullable = a => !isNullable(a);
66
36
 
67
- var none = function () {
68
- return NONE;
69
- };
70
- var NONE = function () {
71
- var call = function (thunk) {
72
- return thunk();
73
- };
74
- var id = identity;
75
- var me = {
76
- fold: function (n, _s) {
77
- return n();
78
- },
79
- isSome: never,
80
- isNone: always,
81
- getOr: id,
82
- getOrThunk: call,
83
- getOrDie: function (msg) {
84
- throw new Error(msg || 'error: getOrDie called on none.');
85
- },
86
- getOrNull: constant(null),
87
- getOrUndefined: constant(undefined),
88
- or: id,
89
- orThunk: call,
90
- map: none,
91
- each: noop,
92
- bind: none,
93
- exists: never,
94
- forall: always,
95
- filter: function () {
96
- return none();
97
- },
98
- toArray: function () {
99
- return [];
100
- },
101
- toString: constant('none()')
102
- };
103
- return me;
104
- }();
105
- var some = function (a) {
106
- var constant_a = constant(a);
107
- var self = function () {
108
- return me;
109
- };
110
- var bind = function (f) {
111
- return f(a);
112
- };
113
- var me = {
114
- fold: function (n, s) {
115
- return s(a);
116
- },
117
- isSome: always,
118
- isNone: never,
119
- getOr: constant_a,
120
- getOrThunk: constant_a,
121
- getOrDie: constant_a,
122
- getOrNull: constant_a,
123
- getOrUndefined: constant_a,
124
- or: self,
125
- orThunk: self,
126
- map: function (f) {
127
- return some(f(a));
128
- },
129
- each: function (f) {
130
- f(a);
131
- },
132
- bind: bind,
133
- exists: bind,
134
- forall: bind,
135
- filter: function (f) {
136
- return f(a) ? me : NONE;
137
- },
138
- toArray: function () {
139
- return [a];
140
- },
141
- toString: function () {
142
- return 'some(' + a + ')';
37
+ class Optional {
38
+ constructor(tag, value) {
39
+ this.tag = tag;
40
+ this.value = value;
41
+ }
42
+ static some(value) {
43
+ return new Optional(true, value);
44
+ }
45
+ static none() {
46
+ return Optional.singletonNone;
47
+ }
48
+ fold(onNone, onSome) {
49
+ if (this.tag) {
50
+ return onSome(this.value);
51
+ } else {
52
+ return onNone();
143
53
  }
144
- };
145
- return me;
146
- };
147
- var from = function (value) {
148
- return value === null || value === undefined ? NONE : some(value);
149
- };
150
- var Optional = {
151
- some: some,
152
- none: none,
153
- from: from
154
- };
54
+ }
55
+ isSome() {
56
+ return this.tag;
57
+ }
58
+ isNone() {
59
+ return !this.tag;
60
+ }
61
+ map(mapper) {
62
+ if (this.tag) {
63
+ return Optional.some(mapper(this.value));
64
+ } else {
65
+ return Optional.none();
66
+ }
67
+ }
68
+ bind(binder) {
69
+ if (this.tag) {
70
+ return binder(this.value);
71
+ } else {
72
+ return Optional.none();
73
+ }
74
+ }
75
+ exists(predicate) {
76
+ return this.tag && predicate(this.value);
77
+ }
78
+ forall(predicate) {
79
+ return !this.tag || predicate(this.value);
80
+ }
81
+ filter(predicate) {
82
+ if (!this.tag || predicate(this.value)) {
83
+ return this;
84
+ } else {
85
+ return Optional.none();
86
+ }
87
+ }
88
+ getOr(replacement) {
89
+ return this.tag ? this.value : replacement;
90
+ }
91
+ or(replacement) {
92
+ return this.tag ? this : replacement;
93
+ }
94
+ getOrThunk(thunk) {
95
+ return this.tag ? this.value : thunk();
96
+ }
97
+ orThunk(thunk) {
98
+ return this.tag ? this : thunk();
99
+ }
100
+ getOrDie(message) {
101
+ if (!this.tag) {
102
+ throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
103
+ } else {
104
+ return this.value;
105
+ }
106
+ }
107
+ static from(value) {
108
+ return isNonNullable(value) ? Optional.some(value) : Optional.none();
109
+ }
110
+ getOrNull() {
111
+ return this.tag ? this.value : null;
112
+ }
113
+ getOrUndefined() {
114
+ return this.value;
115
+ }
116
+ each(worker) {
117
+ if (this.tag) {
118
+ worker(this.value);
119
+ }
120
+ }
121
+ toArray() {
122
+ return this.tag ? [this.value] : [];
123
+ }
124
+ toString() {
125
+ return this.tag ? `some(${ this.value })` : 'none()';
126
+ }
127
+ }
128
+ Optional.singletonNone = new Optional(false);
155
129
 
156
- var nativePush = Array.prototype.push;
157
- var each$1 = function (xs, f) {
158
- for (var i = 0, len = xs.length; i < len; i++) {
159
- var x = xs[i];
130
+ const nativePush = Array.prototype.push;
131
+ const each$1 = (xs, f) => {
132
+ for (let i = 0, len = xs.length; i < len; i++) {
133
+ const x = xs[i];
160
134
  f(x, i);
161
135
  }
162
136
  };
163
- var flatten = function (xs) {
164
- var r = [];
165
- for (var i = 0, len = xs.length; i < len; ++i) {
137
+ const flatten = xs => {
138
+ const r = [];
139
+ for (let i = 0, len = xs.length; i < len; ++i) {
166
140
  if (!isArray(xs[i])) {
167
141
  throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
168
142
  }
@@ -171,150 +145,138 @@
171
145
  return r;
172
146
  };
173
147
 
174
- var Cell = function (initial) {
175
- var value = initial;
176
- var get = function () {
148
+ const Cell = initial => {
149
+ let value = initial;
150
+ const get = () => {
177
151
  return value;
178
152
  };
179
- var set = function (v) {
153
+ const set = v => {
180
154
  value = v;
181
155
  };
182
156
  return {
183
- get: get,
184
- set: set
157
+ get,
158
+ set
185
159
  };
186
160
  };
187
161
 
188
- var keys = Object.keys;
189
- var hasOwnProperty = Object.hasOwnProperty;
190
- var each = function (obj, f) {
191
- var props = keys(obj);
192
- for (var k = 0, len = props.length; k < len; k++) {
193
- var i = props[k];
194
- var x = obj[i];
162
+ const keys = Object.keys;
163
+ const hasOwnProperty = Object.hasOwnProperty;
164
+ const each = (obj, f) => {
165
+ const props = keys(obj);
166
+ for (let k = 0, len = props.length; k < len; k++) {
167
+ const i = props[k];
168
+ const x = obj[i];
195
169
  f(x, i);
196
170
  }
197
171
  };
198
- var get$1 = function (obj, key) {
172
+ const get$1 = (obj, key) => {
199
173
  return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
200
174
  };
201
- var has = function (obj, key) {
202
- return hasOwnProperty.call(obj, key);
203
- };
175
+ const has = (obj, key) => hasOwnProperty.call(obj, key);
204
176
 
205
- var getScripts = function (editor) {
206
- return editor.getParam('media_scripts');
207
- };
208
- var getAudioTemplateCallback = function (editor) {
209
- return editor.getParam('audio_template_callback');
210
- };
211
- var getVideoTemplateCallback = function (editor) {
212
- return editor.getParam('video_template_callback');
213
- };
214
- var hasLiveEmbeds = function (editor) {
215
- return editor.getParam('media_live_embeds', true);
216
- };
217
- var shouldFilterHtml = function (editor) {
218
- return editor.getParam('media_filter_html', true);
219
- };
220
- var getUrlResolver = function (editor) {
221
- return editor.getParam('media_url_resolver');
222
- };
223
- var hasAltSource = function (editor) {
224
- return editor.getParam('media_alt_source', true);
225
- };
226
- var hasPoster = function (editor) {
227
- return editor.getParam('media_poster', true);
228
- };
229
- var hasDimensions = function (editor) {
230
- return editor.getParam('media_dimensions', true);
177
+ const option = name => editor => editor.options.get(name);
178
+ const register$2 = editor => {
179
+ const registerOption = editor.options.register;
180
+ registerOption('audio_template_callback', { processor: 'function' });
181
+ registerOption('video_template_callback', { processor: 'function' });
182
+ registerOption('iframe_template_callback', { processor: 'function' });
183
+ registerOption('media_live_embeds', {
184
+ processor: 'boolean',
185
+ default: true
186
+ });
187
+ registerOption('media_filter_html', {
188
+ processor: 'boolean',
189
+ default: true
190
+ });
191
+ registerOption('media_url_resolver', { processor: 'function' });
192
+ registerOption('media_alt_source', {
193
+ processor: 'boolean',
194
+ default: true
195
+ });
196
+ registerOption('media_poster', {
197
+ processor: 'boolean',
198
+ default: true
199
+ });
200
+ registerOption('media_dimensions', {
201
+ processor: 'boolean',
202
+ default: true
203
+ });
231
204
  };
205
+ const getAudioTemplateCallback = option('audio_template_callback');
206
+ const getVideoTemplateCallback = option('video_template_callback');
207
+ const getIframeTemplateCallback = option('iframe_template_callback');
208
+ const hasLiveEmbeds = option('media_live_embeds');
209
+ const shouldFilterHtml = option('media_filter_html');
210
+ const getUrlResolver = option('media_url_resolver');
211
+ const hasAltSource = option('media_alt_source');
212
+ const hasPoster = option('media_poster');
213
+ const hasDimensions = option('media_dimensions');
232
214
 
233
- var global$8 = tinymce.util.Tools.resolve('tinymce.util.Tools');
215
+ var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools');
234
216
 
235
- var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
217
+ var global$4 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
236
218
 
237
- var global$6 = tinymce.util.Tools.resolve('tinymce.html.SaxParser');
219
+ var global$3 = tinymce.util.Tools.resolve('tinymce.html.DomParser');
238
220
 
239
- var getVideoScriptMatch = function (prefixes, src) {
240
- if (prefixes) {
241
- for (var i = 0; i < prefixes.length; i++) {
242
- if (src.indexOf(prefixes[i].filter) !== -1) {
243
- return prefixes[i];
244
- }
245
- }
246
- }
247
- };
248
-
249
- var DOM$1 = global$7.DOM;
250
- var trimPx = function (value) {
251
- return value.replace(/px$/, '');
252
- };
253
- var getEphoxEmbedData = function (attrs) {
254
- var style = attrs.map.style;
255
- var styles = style ? DOM$1.parseStyle(style) : {};
221
+ const DOM$1 = global$4.DOM;
222
+ const trimPx = value => value.replace(/px$/, '');
223
+ const getEphoxEmbedData = node => {
224
+ const style = node.attr('style');
225
+ const styles = style ? DOM$1.parseStyle(style) : {};
256
226
  return {
257
227
  type: 'ephox-embed-iri',
258
- source: attrs.map['data-ephox-embed-iri'],
228
+ source: node.attr('data-ephox-embed-iri'),
259
229
  altsource: '',
260
230
  poster: '',
261
231
  width: get$1(styles, 'max-width').map(trimPx).getOr(''),
262
232
  height: get$1(styles, 'max-height').map(trimPx).getOr('')
263
233
  };
264
234
  };
265
- var htmlToData = function (prefixes, html) {
266
- var isEphoxEmbed = Cell(false);
267
- var data = {};
268
- global$6({
235
+ const htmlToData = (html, schema) => {
236
+ let data = {};
237
+ const parser = global$3({
269
238
  validate: false,
270
- allow_conditional_comments: true,
271
- start: function (name, attrs) {
272
- if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
273
- isEphoxEmbed.set(true);
274
- data = getEphoxEmbedData(attrs);
239
+ forced_root_block: false
240
+ }, schema);
241
+ const rootNode = parser.parse(html);
242
+ for (let node = rootNode; node; node = node.walk()) {
243
+ if (node.type === 1) {
244
+ const name = node.name;
245
+ if (node.attr('data-ephox-embed-iri')) {
246
+ data = getEphoxEmbedData(node);
247
+ break;
275
248
  } else {
276
249
  if (!data.source && name === 'param') {
277
- data.source = attrs.map.movie;
250
+ data.source = node.attr('movie');
278
251
  }
279
252
  if (name === 'iframe' || name === 'object' || name === 'embed' || name === 'video' || name === 'audio') {
280
253
  if (!data.type) {
281
254
  data.type = name;
282
255
  }
283
- data = global$8.extend(attrs.map, data);
284
- }
285
- if (name === 'script') {
286
- var videoScript = getVideoScriptMatch(prefixes, attrs.map.src);
287
- if (!videoScript) {
288
- return;
289
- }
290
- data = {
291
- type: 'script',
292
- source: attrs.map.src,
293
- width: String(videoScript.width),
294
- height: String(videoScript.height)
295
- };
256
+ data = global$5.extend(node.attributes.map, data);
296
257
  }
297
258
  if (name === 'source') {
298
259
  if (!data.source) {
299
- data.source = attrs.map.src;
260
+ data.source = node.attr('src');
300
261
  } else if (!data.altsource) {
301
- data.altsource = attrs.map.src;
262
+ data.altsource = node.attr('src');
302
263
  }
303
264
  }
304
265
  if (name === 'img' && !data.poster) {
305
- data.poster = attrs.map.src;
266
+ data.poster = node.attr('src');
306
267
  }
307
268
  }
308
269
  }
309
- }).parse(html);
310
- data.source = data.source || data.src || data.data;
270
+ }
271
+ data.source = data.source || data.src || '';
311
272
  data.altsource = data.altsource || '';
312
273
  data.poster = data.poster || '';
313
274
  return data;
314
275
  };
315
276
 
316
- var guess = function (url) {
317
- var mimes = {
277
+ const guess = url => {
278
+ var _a;
279
+ const mimes = {
318
280
  mp3: 'audio/mpeg',
319
281
  m4a: 'audio/x-m4a',
320
282
  wav: 'audio/wav',
@@ -323,77 +285,50 @@
323
285
  ogg: 'video/ogg',
324
286
  swf: 'application/x-shockwave-flash'
325
287
  };
326
- var fileEnd = url.toLowerCase().split('.').pop();
327
- var mime = mimes[fileEnd];
328
- return mime ? mime : '';
288
+ const fileEnd = (_a = url.toLowerCase().split('.').pop()) !== null && _a !== void 0 ? _a : '';
289
+ return get$1(mimes, fileEnd).getOr('');
329
290
  };
330
291
 
331
- var global$5 = tinymce.util.Tools.resolve('tinymce.html.Schema');
292
+ var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node');
332
293
 
333
- var global$4 = tinymce.util.Tools.resolve('tinymce.html.Writer');
294
+ var global$1 = tinymce.util.Tools.resolve('tinymce.html.Serializer');
334
295
 
335
- var DOM = global$7.DOM;
336
- var addPx = function (value) {
337
- return /^[0-9.]+$/.test(value) ? value + 'px' : value;
338
- };
339
- var setAttributes = function (attrs, updatedAttrs) {
340
- each(updatedAttrs, function (val, name) {
341
- var value = '' + val;
342
- if (attrs.map[name]) {
343
- var i = attrs.length;
344
- while (i--) {
345
- var attr = attrs[i];
346
- if (attr.name === name) {
347
- if (value) {
348
- attrs.map[name] = value;
349
- attr.value = value;
350
- } else {
351
- delete attrs.map[name];
352
- attrs.splice(i, 1);
353
- }
354
- }
355
- }
356
- } else if (value) {
357
- attrs.push({
358
- name: name,
359
- value: value
360
- });
361
- attrs.map[name] = value;
362
- }
363
- });
364
- };
365
- var updateEphoxEmbed = function (data, attrs) {
366
- var style = attrs.map.style;
367
- var styleMap = style ? DOM.parseStyle(style) : {};
368
- styleMap['max-width'] = addPx(data.width);
369
- styleMap['max-height'] = addPx(data.height);
370
- setAttributes(attrs, { style: DOM.serializeStyle(styleMap) });
296
+ const Parser = (schema, settings = {}) => global$3({
297
+ forced_root_block: false,
298
+ validate: false,
299
+ allow_conditional_comments: true,
300
+ ...settings
301
+ }, schema);
302
+
303
+ const DOM = global$4.DOM;
304
+ const addPx = value => /^[0-9.]+$/.test(value) ? value + 'px' : value;
305
+ const updateEphoxEmbed = (data, node) => {
306
+ const style = node.attr('style');
307
+ const styleMap = style ? DOM.parseStyle(style) : {};
308
+ if (isNonNullable(data.width)) {
309
+ styleMap['max-width'] = addPx(data.width);
310
+ }
311
+ if (isNonNullable(data.height)) {
312
+ styleMap['max-height'] = addPx(data.height);
313
+ }
314
+ node.attr('style', DOM.serializeStyle(styleMap));
371
315
  };
372
- var sources = [
316
+ const sources = [
373
317
  'source',
374
318
  'altsource'
375
319
  ];
376
- var updateHtml = function (html, data, updateAll) {
377
- var writer = global$4();
378
- var isEphoxEmbed = Cell(false);
379
- var sourceCount = 0;
380
- var hasImage;
381
- global$6({
382
- validate: false,
383
- allow_conditional_comments: true,
384
- comment: function (text) {
385
- writer.comment(text);
386
- },
387
- cdata: function (text) {
388
- writer.cdata(text);
389
- },
390
- text: function (text, raw) {
391
- writer.text(text, raw);
392
- },
393
- start: function (name, attrs, empty) {
394
- if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
395
- isEphoxEmbed.set(true);
396
- updateEphoxEmbed(data, attrs);
320
+ const updateHtml = (html, data, updateAll, schema) => {
321
+ let numSources = 0;
322
+ let sourceCount = 0;
323
+ const parser = Parser(schema);
324
+ parser.addNodeFilter('source', nodes => numSources = nodes.length);
325
+ const rootNode = parser.parse(html);
326
+ for (let node = rootNode; node; node = node.walk()) {
327
+ if (node.type === 1) {
328
+ const name = node.name;
329
+ if (node.attr('data-ephox-embed-iri')) {
330
+ updateEphoxEmbed(data, node);
331
+ break;
397
332
  } else {
398
333
  switch (name) {
399
334
  case 'video':
@@ -402,85 +337,64 @@
402
337
  case 'img':
403
338
  case 'iframe':
404
339
  if (data.height !== undefined && data.width !== undefined) {
405
- setAttributes(attrs, {
406
- width: data.width,
407
- height: data.height
408
- });
340
+ node.attr('width', data.width);
341
+ node.attr('height', data.height);
409
342
  }
410
343
  break;
411
344
  }
412
345
  if (updateAll) {
413
346
  switch (name) {
414
347
  case 'video':
415
- setAttributes(attrs, {
416
- poster: data.poster,
417
- src: ''
418
- });
419
- if (data.altsource) {
420
- setAttributes(attrs, { src: '' });
348
+ node.attr('poster', data.poster);
349
+ node.attr('src', null);
350
+ for (let index = numSources; index < 2; index++) {
351
+ if (data[sources[index]]) {
352
+ const source = new global$2('source', 1);
353
+ source.attr('src', data[sources[index]]);
354
+ source.attr('type', data[sources[index] + 'mime'] || null);
355
+ node.append(source);
356
+ }
421
357
  }
422
358
  break;
423
359
  case 'iframe':
424
- setAttributes(attrs, { src: data.source });
360
+ node.attr('src', data.source);
361
+ break;
362
+ case 'object':
363
+ const hasImage = node.getAll('img').length > 0;
364
+ if (data.poster && !hasImage) {
365
+ node.attr('src', data.poster);
366
+ const img = new global$2('img', 1);
367
+ img.attr('src', data.poster);
368
+ img.attr('width', data.width);
369
+ img.attr('height', data.height);
370
+ node.append(img);
371
+ }
425
372
  break;
426
373
  case 'source':
427
374
  if (sourceCount < 2) {
428
- setAttributes(attrs, {
429
- src: data[sources[sourceCount]],
430
- type: data[sources[sourceCount] + 'mime']
431
- });
375
+ node.attr('src', data[sources[sourceCount]]);
376
+ node.attr('type', data[sources[sourceCount] + 'mime'] || null);
432
377
  if (!data[sources[sourceCount]]) {
433
- return;
378
+ node.remove();
379
+ continue;
434
380
  }
435
381
  }
436
382
  sourceCount++;
437
383
  break;
438
384
  case 'img':
439
385
  if (!data.poster) {
440
- return;
386
+ node.remove();
441
387
  }
442
- hasImage = true;
443
388
  break;
444
389
  }
445
390
  }
446
391
  }
447
- writer.start(name, attrs, empty);
448
- },
449
- end: function (name) {
450
- if (!isEphoxEmbed.get()) {
451
- if (name === 'video' && updateAll) {
452
- for (var index = 0; index < 2; index++) {
453
- if (data[sources[index]]) {
454
- var attrs = [];
455
- attrs.map = {};
456
- if (sourceCount <= index) {
457
- setAttributes(attrs, {
458
- src: data[sources[index]],
459
- type: data[sources[index] + 'mime']
460
- });
461
- writer.start('source', attrs, true);
462
- }
463
- }
464
- }
465
- }
466
- if (data.poster && name === 'object' && updateAll && !hasImage) {
467
- var imgAttrs = [];
468
- imgAttrs.map = {};
469
- setAttributes(imgAttrs, {
470
- src: data.poster,
471
- width: data.width,
472
- height: data.height
473
- });
474
- writer.start('img', imgAttrs, true);
475
- }
476
- }
477
- writer.end(name);
478
392
  }
479
- }, global$5({})).parse(html);
480
- return writer.getContent();
393
+ }
394
+ return global$1({}, schema).serialize(rootNode);
481
395
  };
482
396
 
483
- var urlPatterns = [
397
+ const urlPatterns = [
484
398
  {
485
399
  regex: /youtu\.be\/([\w\-_\?&=.]+)/i,
486
400
  type: 'iframe',
@@ -505,6 +419,22 @@
505
419
  url: 'www.youtube.com/embed/$1',
506
420
  allowFullscreen: true
507
421
  },
422
+ {
423
+ regex: /vimeo\.com\/([0-9]+)\?h=(\w+)/,
424
+ type: 'iframe',
425
+ w: 425,
426
+ h: 350,
427
+ url: 'player.vimeo.com/video/$1?h=$2&title=0&byline=0&portrait=0&color=8dc7dc',
428
+ allowFullscreen: true
429
+ },
430
+ {
431
+ regex: /vimeo\.com\/(.*)\/([0-9]+)\?h=(\w+)/,
432
+ type: 'iframe',
433
+ w: 425,
434
+ h: 350,
435
+ url: 'player.vimeo.com/video/$2?h=$3&title=0&amp;byline=0',
436
+ allowFullscreen: true
437
+ },
508
438
  {
509
439
  regex: /vimeo\.com\/([0-9]+)/,
510
440
  type: 'iframe',
@@ -546,72 +476,69 @@
546
476
  allowFullscreen: true
547
477
  }
548
478
  ];
549
- var getProtocol = function (url) {
550
- var protocolMatches = url.match(/^(https?:\/\/|www\.)(.+)$/i);
479
+ const getProtocol = url => {
480
+ const protocolMatches = url.match(/^(https?:\/\/|www\.)(.+)$/i);
551
481
  if (protocolMatches && protocolMatches.length > 1) {
552
482
  return protocolMatches[1] === 'www.' ? 'https://' : protocolMatches[1];
553
483
  } else {
554
484
  return 'https://';
555
485
  }
556
486
  };
557
- var getUrl = function (pattern, url) {
558
- var protocol = getProtocol(url);
559
- var match = pattern.regex.exec(url);
560
- var newUrl = protocol + pattern.url;
561
- var _loop_1 = function (i) {
562
- newUrl = newUrl.replace('$' + i, function () {
563
- return match[i] ? match[i] : '';
564
- });
565
- };
566
- for (var i = 0; i < match.length; i++) {
567
- _loop_1(i);
487
+ const getUrl = (pattern, url) => {
488
+ const protocol = getProtocol(url);
489
+ const match = pattern.regex.exec(url);
490
+ let newUrl = protocol + pattern.url;
491
+ if (isNonNullable(match)) {
492
+ for (let i = 0; i < match.length; i++) {
493
+ newUrl = newUrl.replace('$' + i, () => match[i] ? match[i] : '');
494
+ }
568
495
  }
569
496
  return newUrl.replace(/\?$/, '');
570
497
  };
571
- var matchPattern = function (url) {
572
- var patterns = urlPatterns.filter(function (pattern) {
573
- return pattern.regex.test(url);
574
- });
498
+ const matchPattern = url => {
499
+ const patterns = urlPatterns.filter(pattern => pattern.regex.test(url));
575
500
  if (patterns.length > 0) {
576
- return global$8.extend({}, patterns[0], { url: getUrl(patterns[0], url) });
501
+ return global$5.extend({}, patterns[0], { url: getUrl(patterns[0], url) });
577
502
  } else {
578
503
  return null;
579
504
  }
580
505
  };
581
506
 
582
- var getIframeHtml = function (data) {
583
- var allowFullscreen = data.allowfullscreen ? ' allowFullscreen="1"' : '';
584
- return '<iframe src="' + data.source + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
507
+ const getIframeHtml = (data, iframeTemplateCallback) => {
508
+ if (iframeTemplateCallback) {
509
+ return iframeTemplateCallback(data);
510
+ } else {
511
+ const allowFullscreen = data.allowfullscreen ? ' allowFullscreen="1"' : '';
512
+ return '<iframe src="' + data.source + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
513
+ }
585
514
  };
586
- var getFlashHtml = function (data) {
587
- var html = '<object data="' + data.source + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
515
+ const getFlashHtml = data => {
516
+ let html = '<object data="' + data.source + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
588
517
  if (data.poster) {
589
518
  html += '<img src="' + data.poster + '" width="' + data.width + '" height="' + data.height + '" />';
590
519
  }
591
520
  html += '</object>';
592
521
  return html;
593
522
  };
594
- var getAudioHtml = function (data, audioTemplateCallback) {
523
+ const getAudioHtml = (data, audioTemplateCallback) => {
595
524
  if (audioTemplateCallback) {
596
525
  return audioTemplateCallback(data);
597
526
  } else {
598
527
  return '<audio controls="controls" src="' + data.source + '">' + (data.altsource ? '\n<source src="' + data.altsource + '"' + (data.altsourcemime ? ' type="' + data.altsourcemime + '"' : '') + ' />\n' : '') + '</audio>';
599
528
  }
600
529
  };
601
- var getVideoHtml = function (data, videoTemplateCallback) {
530
+ const getVideoHtml = (data, videoTemplateCallback) => {
602
531
  if (videoTemplateCallback) {
603
532
  return videoTemplateCallback(data);
604
533
  } else {
605
534
  return '<video width="' + data.width + '" height="' + data.height + '"' + (data.poster ? ' poster="' + data.poster + '"' : '') + ' controls="controls">\n' + '<source src="' + data.source + '"' + (data.sourcemime ? ' type="' + data.sourcemime + '"' : '') + ' />\n' + (data.altsource ? '<source src="' + data.altsource + '"' + (data.altsourcemime ? ' type="' + data.altsourcemime + '"' : '') + ' />\n' : '') + '</video>';
606
535
  }
607
536
  };
608
- var getScriptHtml = function (data) {
609
- return '<script src="' + data.source + '"></script>';
610
- };
611
- var dataToHtml = function (editor, dataIn) {
612
- var data = global$8.extend({}, dataIn);
537
+ const dataToHtml = (editor, dataIn) => {
538
+ var _a;
539
+ const data = global$5.extend({}, dataIn);
613
540
  if (!data.source) {
614
- global$8.extend(data, htmlToData(getScripts(editor), data.embed));
541
+ global$5.extend(data, htmlToData((_a = data.embed) !== null && _a !== void 0 ? _a : '', editor.schema));
615
542
  if (!data.source) {
616
543
  return '';
617
544
  }
@@ -627,7 +554,7 @@
627
554
  data.sourcemime = guess(data.source);
628
555
  data.altsourcemime = guess(data.altsource);
629
556
  data.poster = editor.convertURL(data.poster, 'poster');
630
- var pattern = matchPattern(data.source);
557
+ const pattern = matchPattern(data.source);
631
558
  if (pattern) {
632
559
  data.source = pattern.url;
633
560
  data.type = pattern.type;
@@ -636,74 +563,57 @@
636
563
  data.height = data.height || String(pattern.h);
637
564
  }
638
565
  if (data.embed) {
639
- return updateHtml(data.embed, data, true);
566
+ return updateHtml(data.embed, data, true, editor.schema);
640
567
  } else {
641
- var videoScript = getVideoScriptMatch(getScripts(editor), data.source);
642
- if (videoScript) {
643
- data.type = 'script';
644
- data.width = String(videoScript.width);
645
- data.height = String(videoScript.height);
646
- }
647
- var audioTemplateCallback = getAudioTemplateCallback(editor);
648
- var videoTemplateCallback = getVideoTemplateCallback(editor);
568
+ const audioTemplateCallback = getAudioTemplateCallback(editor);
569
+ const videoTemplateCallback = getVideoTemplateCallback(editor);
570
+ const iframeTemplateCallback = getIframeTemplateCallback(editor);
649
571
  data.width = data.width || '300';
650
572
  data.height = data.height || '150';
651
- global$8.each(data, function (value, key) {
573
+ global$5.each(data, (value, key) => {
652
574
  data[key] = editor.dom.encode('' + value);
653
575
  });
654
576
  if (data.type === 'iframe') {
655
- return getIframeHtml(data);
577
+ return getIframeHtml(data, iframeTemplateCallback);
656
578
  } else if (data.sourcemime === 'application/x-shockwave-flash') {
657
579
  return getFlashHtml(data);
658
580
  } else if (data.sourcemime.indexOf('audio') !== -1) {
659
581
  return getAudioHtml(data, audioTemplateCallback);
660
- } else if (data.type === 'script') {
661
- return getScriptHtml(data);
662
582
  } else {
663
583
  return getVideoHtml(data, videoTemplateCallback);
664
584
  }
665
585
  }
666
586
  };
667
587
 
668
- var isMediaElement = function (element) {
669
- return element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri');
670
- };
671
- var setup$2 = function (editor) {
672
- editor.on('click keyup touchend', function () {
673
- var selectedNode = editor.selection.getNode();
588
+ const isMediaElement = element => element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri');
589
+ const setup$2 = editor => {
590
+ editor.on('click keyup touchend', () => {
591
+ const selectedNode = editor.selection.getNode();
674
592
  if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) {
675
593
  if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) {
676
594
  selectedNode.setAttribute('data-mce-selected', '2');
677
595
  }
678
596
  }
679
597
  });
680
- editor.on('ObjectSelected', function (e) {
681
- var objectType = e.target.getAttribute('data-mce-object');
682
- if (objectType === 'script') {
683
- e.preventDefault();
684
- }
685
- });
686
- editor.on('ObjectResized', function (e) {
687
- var target = e.target;
598
+ editor.on('ObjectResized', e => {
599
+ const target = e.target;
688
600
  if (target.getAttribute('data-mce-object')) {
689
- var html = target.getAttribute('data-mce-html');
601
+ let html = target.getAttribute('data-mce-html');
690
602
  if (html) {
691
603
  html = unescape(html);
692
604
  target.setAttribute('data-mce-html', escape(updateHtml(html, {
693
605
  width: String(e.width),
694
606
  height: String(e.height)
695
- })));
607
+ }, false, editor.schema)));
696
608
  }
697
609
  }
698
610
  });
699
611
  };
700
612
 
701
- var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise');
702
-
703
- var cache = {};
704
- var embedPromise = function (data, dataToHtml, handler) {
705
- return new global$3(function (res, rej) {
706
- var wrappedResolve = function (response) {
613
+ const cache = {};
614
+ const embedPromise = (data, dataToHtml, handler) => {
615
+ return new Promise((res, rej) => {
616
+ const wrappedResolve = response => {
707
617
  if (response.html) {
708
618
  cache[data.source] = response;
709
619
  }
@@ -715,138 +625,117 @@
715
625
  if (cache[data.source]) {
716
626
  wrappedResolve(cache[data.source]);
717
627
  } else {
718
- handler({ url: data.source }, wrappedResolve, rej);
628
+ handler({ url: data.source }).then(wrappedResolve).catch(rej);
719
629
  }
720
630
  });
721
631
  };
722
- var defaultPromise = function (data, dataToHtml) {
723
- return global$3.resolve({
724
- html: dataToHtml(data),
725
- url: data.source
726
- });
727
- };
728
- var loadedData = function (editor) {
729
- return function (data) {
730
- return dataToHtml(editor, data);
731
- };
732
- };
733
- var getEmbedHtml = function (editor, data) {
734
- var embedHandler = getUrlResolver(editor);
632
+ const defaultPromise = (data, dataToHtml) => Promise.resolve({
633
+ html: dataToHtml(data),
634
+ url: data.source
635
+ });
636
+ const loadedData = editor => data => dataToHtml(editor, data);
637
+ const getEmbedHtml = (editor, data) => {
638
+ const embedHandler = getUrlResolver(editor);
735
639
  return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor));
736
640
  };
737
- var isCached = function (url) {
738
- return has(cache, url);
739
- };
641
+ const isCached = url => has(cache, url);
740
642
 
741
- var extractMeta = function (sourceInput, data) {
742
- return get$1(data, sourceInput).bind(function (mainData) {
743
- return get$1(mainData, 'meta');
744
- });
745
- };
746
- var getValue = function (data, metaData, sourceInput) {
747
- return function (prop) {
748
- var _a;
749
- var getFromData = function () {
750
- return get$1(data, prop);
751
- };
752
- var getFromMetaData = function () {
753
- return get$1(metaData, prop);
754
- };
755
- var getNonEmptyValue = function (c) {
756
- return get$1(c, 'value').bind(function (v) {
757
- return v.length > 0 ? Optional.some(v) : Optional.none();
758
- });
759
- };
760
- var getFromValueFirst = function () {
761
- return getFromData().bind(function (child) {
762
- return isObject(child) ? getNonEmptyValue(child).orThunk(getFromMetaData) : getFromMetaData().orThunk(function () {
763
- return Optional.from(child);
764
- });
765
- });
766
- };
767
- var getFromMetaFirst = function () {
768
- return getFromMetaData().orThunk(function () {
769
- return getFromData().bind(function (child) {
770
- return isObject(child) ? getNonEmptyValue(child) : Optional.from(child);
771
- });
772
- });
773
- };
774
- return _a = {}, _a[prop] = (prop === sourceInput ? getFromValueFirst() : getFromMetaFirst()).getOr(''), _a;
775
- };
776
- };
777
- var getDimensions = function (data, metaData) {
778
- var dimensions = {};
779
- get$1(data, 'dimensions').each(function (dims) {
643
+ const extractMeta = (sourceInput, data) => get$1(data, sourceInput).bind(mainData => get$1(mainData, 'meta'));
644
+ const getValue = (data, metaData, sourceInput) => prop => {
645
+ const getFromData = () => get$1(data, prop);
646
+ const getFromMetaData = () => get$1(metaData, prop);
647
+ const getNonEmptyValue = c => get$1(c, 'value').bind(v => v.length > 0 ? Optional.some(v) : Optional.none());
648
+ const getFromValueFirst = () => getFromData().bind(child => isObject(child) ? getNonEmptyValue(child).orThunk(getFromMetaData) : getFromMetaData().orThunk(() => Optional.from(child)));
649
+ const getFromMetaFirst = () => getFromMetaData().orThunk(() => getFromData().bind(child => isObject(child) ? getNonEmptyValue(child) : Optional.from(child)));
650
+ return { [prop]: (prop === sourceInput ? getFromValueFirst() : getFromMetaFirst()).getOr('') };
651
+ };
652
+ const getDimensions = (data, metaData) => {
653
+ const dimensions = {};
654
+ get$1(data, 'dimensions').each(dims => {
780
655
  each$1([
781
656
  'width',
782
657
  'height'
783
- ], function (prop) {
784
- get$1(metaData, prop).orThunk(function () {
785
- return get$1(dims, prop);
786
- }).each(function (value) {
787
- return dimensions[prop] = value;
788
- });
658
+ ], prop => {
659
+ get$1(metaData, prop).orThunk(() => get$1(dims, prop)).each(value => dimensions[prop] = value);
789
660
  });
790
661
  });
791
662
  return dimensions;
792
663
  };
793
- var unwrap = function (data, sourceInput) {
794
- var metaData = sourceInput ? extractMeta(sourceInput, data).getOr({}) : {};
795
- var get = getValue(data, metaData, sourceInput);
796
- return __assign(__assign(__assign(__assign(__assign({}, get('source')), get('altsource')), get('poster')), get('embed')), getDimensions(data, metaData));
664
+ const unwrap = (data, sourceInput) => {
665
+ const metaData = sourceInput && sourceInput !== 'dimensions' ? extractMeta(sourceInput, data).getOr({}) : {};
666
+ const get = getValue(data, metaData, sourceInput);
667
+ return {
668
+ ...get('source'),
669
+ ...get('altsource'),
670
+ ...get('poster'),
671
+ ...get('embed'),
672
+ ...getDimensions(data, metaData)
673
+ };
797
674
  };
798
- var wrap = function (data) {
799
- var wrapped = __assign(__assign({}, data), {
675
+ const wrap = data => {
676
+ const wrapped = {
677
+ ...data,
800
678
  source: { value: get$1(data, 'source').getOr('') },
801
679
  altsource: { value: get$1(data, 'altsource').getOr('') },
802
680
  poster: { value: get$1(data, 'poster').getOr('') }
803
- });
681
+ };
804
682
  each$1([
805
683
  'width',
806
684
  'height'
807
- ], function (prop) {
808
- get$1(data, prop).each(function (value) {
809
- var dimensions = wrapped.dimensions || {};
685
+ ], prop => {
686
+ get$1(data, prop).each(value => {
687
+ const dimensions = wrapped.dimensions || {};
810
688
  dimensions[prop] = value;
811
689
  wrapped.dimensions = dimensions;
812
690
  });
813
691
  });
814
692
  return wrapped;
815
693
  };
816
- var handleError = function (editor) {
817
- return function (error) {
818
- var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.';
819
- editor.notificationManager.open({
820
- type: 'error',
821
- text: errorMessage
822
- });
823
- };
824
- };
825
- var snippetToData = function (editor, embedSnippet) {
826
- return htmlToData(getScripts(editor), embedSnippet);
827
- };
828
- var getEditorData = function (editor) {
829
- var element = editor.selection.getNode();
830
- var snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : '';
831
- return __assign({ embed: snippet }, htmlToData(getScripts(editor), snippet));
694
+ const handleError = editor => error => {
695
+ const errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.';
696
+ editor.notificationManager.open({
697
+ type: 'error',
698
+ text: errorMessage
699
+ });
832
700
  };
833
- var addEmbedHtml = function (api, editor) {
834
- return function (response) {
835
- if (isString(response.url) && response.url.trim().length > 0) {
836
- var html = response.html;
837
- var snippetData = snippetToData(editor, html);
838
- var nuData = __assign(__assign({}, snippetData), {
839
- source: response.url,
840
- embed: html
841
- });
842
- api.setData(wrap(nuData));
701
+ const getEditorData = editor => {
702
+ const element = editor.selection.getNode();
703
+ const snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : '';
704
+ const data = htmlToData(snippet, editor.schema);
705
+ const getDimensionsOfElement = () => {
706
+ if (isEmbedIframe(data.source, data.type)) {
707
+ const rect = editor.dom.getRect(element);
708
+ return {
709
+ width: rect.w.toString().replace(/px$/, ''),
710
+ height: rect.h.toString().replace(/px$/, '')
711
+ };
712
+ } else {
713
+ return {};
843
714
  }
844
715
  };
716
+ const dimensions = getDimensionsOfElement();
717
+ return {
718
+ embed: snippet,
719
+ ...data,
720
+ ...dimensions
721
+ };
845
722
  };
846
- var selectPlaceholder = function (editor, beforeObjects) {
847
- var afterObjects = editor.dom.select('*[data-mce-object]');
848
- for (var i = 0; i < beforeObjects.length; i++) {
849
- for (var y = afterObjects.length - 1; y >= 0; y--) {
723
+ const addEmbedHtml = (api, editor) => response => {
724
+ if (isString(response.url) && response.url.trim().length > 0) {
725
+ const html = response.html;
726
+ const snippetData = htmlToData(html, editor.schema);
727
+ const nuData = {
728
+ ...snippetData,
729
+ source: response.url,
730
+ embed: html
731
+ };
732
+ api.setData(wrap(nuData));
733
+ }
734
+ };
735
+ const selectPlaceholder = (editor, beforeObjects) => {
736
+ const afterObjects = editor.dom.select('*[data-mce-object]');
737
+ for (let i = 0; i < beforeObjects.length; i++) {
738
+ for (let y = afterObjects.length - 1; y >= 0; y--) {
850
739
  if (beforeObjects[i] === afterObjects[y]) {
851
740
  afterObjects.splice(y, 1);
852
741
  }
@@ -854,28 +743,37 @@
854
743
  }
855
744
  editor.selection.select(afterObjects[0]);
856
745
  };
857
- var handleInsert = function (editor, html) {
858
- var beforeObjects = editor.dom.select('*[data-mce-object]');
746
+ const handleInsert = (editor, html) => {
747
+ const beforeObjects = editor.dom.select('*[data-mce-object]');
859
748
  editor.insertContent(html);
860
749
  selectPlaceholder(editor, beforeObjects);
861
750
  editor.nodeChanged();
862
751
  };
863
- var submitForm = function (prevData, newData, editor) {
864
- newData.embed = updateHtml(newData.embed, newData);
752
+ const isEmbedIframe = (url, mediaDataType) => isNonNullable(mediaDataType) && mediaDataType === 'ephox-embed-iri' && isNonNullable(matchPattern(url));
753
+ const shouldInsertAsNewIframe = (prevData, newData) => {
754
+ const hasDimensionsChanged = (prevData, newData) => prevData.width !== newData.width || prevData.height !== newData.height;
755
+ return hasDimensionsChanged(prevData, newData) && isEmbedIframe(newData.source, prevData.type);
756
+ };
757
+ const submitForm = (prevData, newData, editor) => {
758
+ var _a;
759
+ newData.embed = shouldInsertAsNewIframe(prevData, newData) && hasDimensions(editor) ? dataToHtml(editor, {
760
+ ...newData,
761
+ embed: ''
762
+ }) : updateHtml((_a = newData.embed) !== null && _a !== void 0 ? _a : '', newData, false, editor.schema);
865
763
  if (newData.embed && (prevData.source === newData.source || isCached(newData.source))) {
866
764
  handleInsert(editor, newData.embed);
867
765
  } else {
868
- getEmbedHtml(editor, newData).then(function (response) {
766
+ getEmbedHtml(editor, newData).then(response => {
869
767
  handleInsert(editor, response.html);
870
768
  }).catch(handleError(editor));
871
769
  }
872
770
  };
873
- var showDialog = function (editor) {
874
- var editorData = getEditorData(editor);
875
- var currentData = Cell(editorData);
876
- var initialData = wrap(editorData);
877
- var handleSource = function (prevData, api) {
878
- var serviceData = unwrap(api.getData(), 'source');
771
+ const showDialog = editor => {
772
+ const editorData = getEditorData(editor);
773
+ const currentData = Cell(editorData);
774
+ const initialData = wrap(editorData);
775
+ const handleSource = (prevData, api) => {
776
+ const serviceData = unwrap(api.getData(), 'source');
879
777
  if (prevData.source !== serviceData.source) {
880
778
  addEmbedHtml(win, editor)({
881
779
  url: serviceData.source,
@@ -884,29 +782,38 @@
884
782
  getEmbedHtml(editor, serviceData).then(addEmbedHtml(win, editor)).catch(handleError(editor));
885
783
  }
886
784
  };
887
- var handleEmbed = function (api) {
888
- var data = unwrap(api.getData());
889
- var dataFromEmbed = snippetToData(editor, data.embed);
785
+ const handleEmbed = api => {
786
+ var _a;
787
+ const data = unwrap(api.getData());
788
+ const dataFromEmbed = htmlToData((_a = data.embed) !== null && _a !== void 0 ? _a : '', editor.schema);
890
789
  api.setData(wrap(dataFromEmbed));
891
790
  };
892
- var handleUpdate = function (api, sourceInput) {
893
- var data = unwrap(api.getData(), sourceInput);
894
- var embed = dataToHtml(editor, data);
895
- api.setData(wrap(__assign(__assign({}, data), { embed: embed })));
791
+ const handleUpdate = (api, sourceInput, prevData) => {
792
+ const dialogData = unwrap(api.getData(), sourceInput);
793
+ const data = shouldInsertAsNewIframe(prevData, dialogData) && hasDimensions(editor) ? {
794
+ ...dialogData,
795
+ embed: ''
796
+ } : dialogData;
797
+ const embed = dataToHtml(editor, data);
798
+ api.setData(wrap({
799
+ ...data,
800
+ embed
801
+ }));
896
802
  };
897
- var mediaInput = [{
803
+ const mediaInput = [{
898
804
  name: 'source',
899
805
  type: 'urlinput',
900
806
  filetype: 'media',
901
- label: 'Source'
807
+ label: 'Source',
808
+ picker_text: 'Browse files'
902
809
  }];
903
- var sizeInput = !hasDimensions(editor) ? [] : [{
810
+ const sizeInput = !hasDimensions(editor) ? [] : [{
904
811
  type: 'sizeinput',
905
812
  name: 'dimensions',
906
813
  label: 'Constrain proportions',
907
814
  constrain: true
908
815
  }];
909
- var generalTab = {
816
+ const generalTab = {
910
817
  title: 'General',
911
818
  name: 'general',
912
819
  items: flatten([
@@ -914,16 +821,16 @@
914
821
  sizeInput
915
822
  ])
916
823
  };
917
- var embedTextarea = {
824
+ const embedTextarea = {
918
825
  type: 'textarea',
919
826
  name: 'embed',
920
827
  label: 'Paste your embed code below:'
921
828
  };
922
- var embedTab = {
829
+ const embedTab = {
923
830
  title: 'Embed',
924
831
  items: [embedTextarea]
925
832
  };
926
- var advancedFormItems = [];
833
+ const advancedFormItems = [];
927
834
  if (hasAltSource(editor)) {
928
835
  advancedFormItems.push({
929
836
  name: 'altsource',
@@ -940,26 +847,26 @@
940
847
  label: 'Media poster (Image URL)'
941
848
  });
942
849
  }
943
- var advancedTab = {
850
+ const advancedTab = {
944
851
  title: 'Advanced',
945
852
  name: 'advanced',
946
853
  items: advancedFormItems
947
854
  };
948
- var tabs = [
855
+ const tabs = [
949
856
  generalTab,
950
857
  embedTab
951
858
  ];
952
859
  if (advancedFormItems.length > 0) {
953
860
  tabs.push(advancedTab);
954
861
  }
955
- var body = {
862
+ const body = {
956
863
  type: 'tabpanel',
957
- tabs: tabs
864
+ tabs
958
865
  };
959
- var win = editor.windowManager.open({
866
+ const win = editor.windowManager.open({
960
867
  title: 'Insert/Edit Media',
961
868
  size: 'normal',
962
- body: body,
869
+ body,
963
870
  buttons: [
964
871
  {
965
872
  type: 'cancel',
@@ -973,12 +880,12 @@
973
880
  primary: true
974
881
  }
975
882
  ],
976
- onSubmit: function (api) {
977
- var serviceData = unwrap(api.getData());
883
+ onSubmit: api => {
884
+ const serviceData = unwrap(api.getData());
978
885
  submitForm(currentData.get(), serviceData, editor);
979
886
  api.close();
980
887
  },
981
- onChange: function (api, detail) {
888
+ onChange: (api, detail) => {
982
889
  switch (detail.name) {
983
890
  case 'source':
984
891
  handleSource(currentData.get(), api);
@@ -989,96 +896,42 @@
989
896
  case 'dimensions':
990
897
  case 'altsource':
991
898
  case 'poster':
992
- handleUpdate(api, detail.name);
899
+ handleUpdate(api, detail.name, currentData.get());
993
900
  break;
994
901
  }
995
902
  currentData.set(unwrap(api.getData()));
996
903
  },
997
- initialData: initialData
904
+ initialData
998
905
  });
999
906
  };
1000
907
 
1001
- var get = function (editor) {
1002
- var showDialog$1 = function () {
908
+ const get = editor => {
909
+ const showDialog$1 = () => {
1003
910
  showDialog(editor);
1004
911
  };
1005
912
  return { showDialog: showDialog$1 };
1006
913
  };
1007
914
 
1008
- var register$1 = function (editor) {
1009
- var showDialog$1 = function () {
915
+ const register$1 = editor => {
916
+ const showDialog$1 = () => {
1010
917
  showDialog(editor);
1011
918
  };
1012
919
  editor.addCommand('mceMedia', showDialog$1);
1013
920
  };
1014
921
 
1015
- var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node');
1016
-
1017
- var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
1018
-
1019
- var global = tinymce.util.Tools.resolve('tinymce.html.DomParser');
1020
-
1021
- var sanitize = function (editor, html) {
1022
- if (shouldFilterHtml(editor) === false) {
1023
- return html;
1024
- }
1025
- var writer = global$4();
1026
- var blocked;
1027
- global$6({
1028
- validate: false,
1029
- allow_conditional_comments: false,
1030
- comment: function (text) {
1031
- if (!blocked) {
1032
- writer.comment(text);
1033
- }
1034
- },
1035
- cdata: function (text) {
1036
- if (!blocked) {
1037
- writer.cdata(text);
1038
- }
1039
- },
1040
- text: function (text, raw) {
1041
- if (!blocked) {
1042
- writer.text(text, raw);
1043
- }
1044
- },
1045
- start: function (name, attrs, empty) {
1046
- blocked = true;
1047
- if (name === 'script' || name === 'noscript' || name === 'svg') {
1048
- return;
1049
- }
1050
- for (var i = attrs.length - 1; i >= 0; i--) {
1051
- var attrName = attrs[i].name;
1052
- if (attrName.indexOf('on') === 0) {
1053
- delete attrs.map[attrName];
1054
- attrs.splice(i, 1);
1055
- }
1056
- if (attrName === 'style') {
1057
- attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
1058
- }
1059
- }
1060
- writer.start(name, attrs, empty);
1061
- blocked = false;
1062
- },
1063
- end: function (name) {
1064
- if (blocked) {
1065
- return;
1066
- }
1067
- writer.end(name);
1068
- }
1069
- }, global$5({})).parse(html);
1070
- return writer.getContent();
922
+ const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
923
+ const startsWith = (str, prefix) => {
924
+ return checkRange(str, prefix, 0);
1071
925
  };
1072
926
 
1073
- var isLiveEmbedNode = function (node) {
1074
- var name = node.name;
927
+ var global = tinymce.util.Tools.resolve('tinymce.Env');
928
+
929
+ const isLiveEmbedNode = node => {
930
+ const name = node.name;
1075
931
  return name === 'iframe' || name === 'video' || name === 'audio';
1076
932
  };
1077
- var getDimension = function (node, styles, dimension, defaultValue) {
1078
- if (defaultValue === void 0) {
1079
- defaultValue = null;
1080
- }
1081
- var value = node.attr(dimension);
933
+ const getDimension = (node, styles, dimension, defaultValue = null) => {
934
+ const value = node.attr(dimension);
1082
935
  if (isNonNullable(value)) {
1083
936
  return value;
1084
937
  } else if (!has(styles, dimension)) {
@@ -1087,42 +940,39 @@
1087
940
  return null;
1088
941
  }
1089
942
  };
1090
- var setDimensions = function (node, previewNode, styles) {
1091
- var useDefaults = previewNode.name === 'img' || node.name === 'video';
1092
- var defaultWidth = useDefaults ? '300' : null;
1093
- var fallbackHeight = node.name === 'audio' ? '30' : '150';
1094
- var defaultHeight = useDefaults ? fallbackHeight : null;
943
+ const setDimensions = (node, previewNode, styles) => {
944
+ const useDefaults = previewNode.name === 'img' || node.name === 'video';
945
+ const defaultWidth = useDefaults ? '300' : null;
946
+ const fallbackHeight = node.name === 'audio' ? '30' : '150';
947
+ const defaultHeight = useDefaults ? fallbackHeight : null;
1095
948
  previewNode.attr({
1096
949
  width: getDimension(node, styles, 'width', defaultWidth),
1097
950
  height: getDimension(node, styles, 'height', defaultHeight)
1098
951
  });
1099
952
  };
1100
- var appendNodeContent = function (editor, nodeName, previewNode, html) {
1101
- var newNode = global({
1102
- forced_root_block: false,
1103
- validate: false
1104
- }, editor.schema).parse(html, { context: nodeName });
953
+ const appendNodeContent = (editor, nodeName, previewNode, html) => {
954
+ const newNode = Parser(editor.schema).parse(html, { context: nodeName });
1105
955
  while (newNode.firstChild) {
1106
956
  previewNode.append(newNode.firstChild);
1107
957
  }
1108
958
  };
1109
- var createPlaceholderNode = function (editor, node) {
1110
- var name = node.name;
1111
- var placeHolder = new global$2('img', 1);
1112
- placeHolder.shortEnded = true;
959
+ const createPlaceholderNode = (editor, node) => {
960
+ const name = node.name;
961
+ const placeHolder = new global$2('img', 1);
1113
962
  retainAttributesAndInnerHtml(editor, node, placeHolder);
1114
963
  setDimensions(node, placeHolder, {});
1115
964
  placeHolder.attr({
1116
965
  'style': node.attr('style'),
1117
- 'src': global$1.transparentSrc,
966
+ 'src': global.transparentSrc,
1118
967
  'data-mce-object': name,
1119
968
  'class': 'mce-object mce-object-' + name
1120
969
  });
1121
970
  return placeHolder;
1122
971
  };
1123
- var createPreviewNode = function (editor, node) {
1124
- var name = node.name;
1125
- var previewWrapper = new global$2('span', 1);
972
+ const createPreviewNode = (editor, node) => {
973
+ var _a;
974
+ const name = node.name;
975
+ const previewWrapper = new global$2('span', 1);
1126
976
  previewWrapper.attr({
1127
977
  'contentEditable': 'false',
1128
978
  'style': node.attr('style'),
@@ -1130,8 +980,8 @@
1130
980
  'class': 'mce-preview-object mce-object-' + name
1131
981
  });
1132
982
  retainAttributesAndInnerHtml(editor, node, previewWrapper);
1133
- var styles = editor.dom.parseStyle(node.attr('style'));
1134
- var previewNode = new global$2(name, 1);
983
+ const styles = editor.dom.parseStyle((_a = node.attr('style')) !== null && _a !== void 0 ? _a : '');
984
+ const previewNode = new global$2(name, 1);
1135
985
  setDimensions(node, previewNode, styles);
1136
986
  previewNode.attr({
1137
987
  src: node.attr('src'),
@@ -1141,10 +991,11 @@
1141
991
  if (name === 'iframe') {
1142
992
  previewNode.attr({
1143
993
  allowfullscreen: node.attr('allowfullscreen'),
1144
- frameborder: '0'
994
+ frameborder: '0',
995
+ sandbox: node.attr('sandbox')
1145
996
  });
1146
997
  } else {
1147
- var attrs = [
998
+ const attrs = [
1148
999
  'controls',
1149
1000
  'crossorigin',
1150
1001
  'currentTime',
@@ -1153,122 +1004,119 @@
1153
1004
  'poster',
1154
1005
  'preload'
1155
1006
  ];
1156
- each$1(attrs, function (attrName) {
1007
+ each$1(attrs, attrName => {
1157
1008
  previewNode.attr(attrName, node.attr(attrName));
1158
1009
  });
1159
- var sanitizedHtml = previewWrapper.attr('data-mce-html');
1010
+ const sanitizedHtml = previewWrapper.attr('data-mce-html');
1160
1011
  if (isNonNullable(sanitizedHtml)) {
1161
1012
  appendNodeContent(editor, name, previewNode, unescape(sanitizedHtml));
1162
1013
  }
1163
1014
  }
1164
- var shimNode = new global$2('span', 1);
1015
+ const shimNode = new global$2('span', 1);
1165
1016
  shimNode.attr('class', 'mce-shim');
1166
1017
  previewWrapper.append(previewNode);
1167
1018
  previewWrapper.append(shimNode);
1168
1019
  return previewWrapper;
1169
1020
  };
1170
- var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) {
1171
- var attribs = sourceNode.attributes;
1172
- var ai = attribs.length;
1021
+ const retainAttributesAndInnerHtml = (editor, sourceNode, targetNode) => {
1022
+ var _a;
1023
+ const attribs = (_a = sourceNode.attributes) !== null && _a !== void 0 ? _a : [];
1024
+ let ai = attribs.length;
1173
1025
  while (ai--) {
1174
- var attrName = attribs[ai].name;
1175
- var attrValue = attribs[ai].value;
1176
- if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') {
1026
+ const attrName = attribs[ai].name;
1027
+ let attrValue = attribs[ai].value;
1028
+ if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style' && !startsWith(attrName, 'data-mce-')) {
1177
1029
  if (attrName === 'data' || attrName === 'src') {
1178
1030
  attrValue = editor.convertURL(attrValue, attrName);
1179
1031
  }
1180
1032
  targetNode.attr('data-mce-p-' + attrName, attrValue);
1181
1033
  }
1182
1034
  }
1183
- var innerHtml = sourceNode.firstChild && sourceNode.firstChild.value;
1035
+ const serializer = global$1({ inner: true }, editor.schema);
1036
+ const tempNode = new global$2('div', 1);
1037
+ each$1(sourceNode.children(), child => tempNode.append(child));
1038
+ const innerHtml = serializer.serialize(tempNode);
1184
1039
  if (innerHtml) {
1185
- targetNode.attr('data-mce-html', escape(sanitize(editor, innerHtml)));
1186
- targetNode.firstChild = null;
1040
+ targetNode.attr('data-mce-html', escape(innerHtml));
1041
+ targetNode.empty();
1187
1042
  }
1188
1043
  };
1189
- var isPageEmbedWrapper = function (node) {
1190
- var nodeClass = node.attr('class');
1191
- return nodeClass && /\btiny-pageembed\b/.test(nodeClass);
1044
+ const isPageEmbedWrapper = node => {
1045
+ const nodeClass = node.attr('class');
1046
+ return isString(nodeClass) && /\btiny-pageembed\b/.test(nodeClass);
1192
1047
  };
1193
- var isWithinEmbedWrapper = function (node) {
1194
- while (node = node.parent) {
1195
- if (node.attr('data-ephox-embed-iri') || isPageEmbedWrapper(node)) {
1048
+ const isWithinEmbedWrapper = node => {
1049
+ let tempNode = node;
1050
+ while (tempNode = tempNode.parent) {
1051
+ if (tempNode.attr('data-ephox-embed-iri') || isPageEmbedWrapper(tempNode)) {
1196
1052
  return true;
1197
1053
  }
1198
1054
  }
1199
1055
  return false;
1200
1056
  };
1201
- var placeHolderConverter = function (editor) {
1202
- return function (nodes) {
1203
- var i = nodes.length;
1204
- var node;
1205
- var videoScript;
1206
- while (i--) {
1207
- node = nodes[i];
1208
- if (!node.parent) {
1209
- continue;
1210
- }
1211
- if (node.parent.attr('data-mce-object')) {
1212
- continue;
1213
- }
1214
- if (node.name === 'script') {
1215
- videoScript = getVideoScriptMatch(getScripts(editor), node.attr('src'));
1216
- if (!videoScript) {
1217
- continue;
1218
- }
1219
- }
1220
- if (videoScript) {
1221
- if (videoScript.width) {
1222
- node.attr('width', videoScript.width.toString());
1223
- }
1224
- if (videoScript.height) {
1225
- node.attr('height', videoScript.height.toString());
1226
- }
1057
+ const placeHolderConverter = editor => nodes => {
1058
+ let i = nodes.length;
1059
+ let node;
1060
+ while (i--) {
1061
+ node = nodes[i];
1062
+ if (!node.parent) {
1063
+ continue;
1064
+ }
1065
+ if (node.parent.attr('data-mce-object')) {
1066
+ continue;
1067
+ }
1068
+ if (isLiveEmbedNode(node) && hasLiveEmbeds(editor)) {
1069
+ if (!isWithinEmbedWrapper(node)) {
1070
+ node.replace(createPreviewNode(editor, node));
1227
1071
  }
1228
- if (isLiveEmbedNode(node) && hasLiveEmbeds(editor) && global$1.ceFalse) {
1229
- if (!isWithinEmbedWrapper(node)) {
1230
- node.replace(createPreviewNode(editor, node));
1231
- }
1232
- } else {
1233
- if (!isWithinEmbedWrapper(node)) {
1234
- node.replace(createPlaceholderNode(editor, node));
1235
- }
1072
+ } else {
1073
+ if (!isWithinEmbedWrapper(node)) {
1074
+ node.replace(createPlaceholderNode(editor, node));
1236
1075
  }
1237
1076
  }
1238
- };
1077
+ }
1239
1078
  };
1240
1079
 
1241
- var setup$1 = function (editor) {
1242
- editor.on('preInit', function () {
1243
- var specialElements = editor.schema.getSpecialElements();
1244
- global$8.each('video audio iframe object'.split(' '), function (name) {
1245
- specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi');
1246
- });
1247
- var boolAttrs = editor.schema.getBoolAttrs();
1248
- global$8.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) {
1080
+ const parseAndSanitize = (editor, context, html) => {
1081
+ const getEditorOption = editor.options.get;
1082
+ const sanitize = getEditorOption('xss_sanitization');
1083
+ const validate = shouldFilterHtml(editor);
1084
+ return Parser(editor.schema, {
1085
+ sanitize,
1086
+ validate
1087
+ }).parse(html, { context });
1088
+ };
1089
+
1090
+ const setup$1 = editor => {
1091
+ editor.on('PreInit', () => {
1092
+ const {schema, serializer, parser} = editor;
1093
+ const boolAttrs = schema.getBoolAttrs();
1094
+ each$1('webkitallowfullscreen mozallowfullscreen'.split(' '), name => {
1249
1095
  boolAttrs[name] = {};
1250
1096
  });
1251
- editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', placeHolderConverter(editor));
1252
- editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) {
1253
- var i = nodes.length;
1254
- var node;
1255
- var realElm;
1256
- var ai;
1257
- var attribs;
1258
- var innerHtml;
1259
- var innerNode;
1260
- var realElmName;
1261
- var className;
1097
+ each({ embed: ['wmode'] }, (attrs, name) => {
1098
+ const rule = schema.getElementRule(name);
1099
+ if (rule) {
1100
+ each$1(attrs, attr => {
1101
+ rule.attributes[attr] = {};
1102
+ rule.attributesOrder.push(attr);
1103
+ });
1104
+ }
1105
+ });
1106
+ parser.addNodeFilter('iframe,video,audio,object,embed', placeHolderConverter(editor));
1107
+ serializer.addAttributeFilter('data-mce-object', (nodes, name) => {
1108
+ var _a;
1109
+ let i = nodes.length;
1262
1110
  while (i--) {
1263
- node = nodes[i];
1111
+ const node = nodes[i];
1264
1112
  if (!node.parent) {
1265
1113
  continue;
1266
1114
  }
1267
- realElmName = node.attr(name);
1268
- realElm = new global$2(realElmName, 1);
1269
- if (realElmName !== 'audio' && realElmName !== 'script') {
1270
- className = node.attr('class');
1271
- if (className && className.indexOf('mce-preview-object') !== -1) {
1115
+ const realElmName = node.attr(name);
1116
+ const realElm = new global$2(realElmName, 1);
1117
+ if (realElmName !== 'audio') {
1118
+ const className = node.attr('class');
1119
+ if (className && className.indexOf('mce-preview-object') !== -1 && node.firstChild) {
1272
1120
  realElm.attr({
1273
1121
  width: node.firstChild.attr('width'),
1274
1122
  height: node.firstChild.attr('height')
@@ -1281,70 +1129,80 @@
1281
1129
  }
1282
1130
  }
1283
1131
  realElm.attr({ style: node.attr('style') });
1284
- attribs = node.attributes;
1285
- ai = attribs.length;
1132
+ const attribs = (_a = node.attributes) !== null && _a !== void 0 ? _a : [];
1133
+ let ai = attribs.length;
1286
1134
  while (ai--) {
1287
- var attrName = attribs[ai].name;
1135
+ const attrName = attribs[ai].name;
1288
1136
  if (attrName.indexOf('data-mce-p-') === 0) {
1289
1137
  realElm.attr(attrName.substr(11), attribs[ai].value);
1290
1138
  }
1291
1139
  }
1292
- if (realElmName === 'script') {
1293
- realElm.attr('type', 'text/javascript');
1294
- }
1295
- innerHtml = node.attr('data-mce-html');
1140
+ const innerHtml = node.attr('data-mce-html');
1296
1141
  if (innerHtml) {
1297
- innerNode = new global$2('#text', 3);
1298
- innerNode.raw = true;
1299
- innerNode.value = sanitize(editor, unescape(innerHtml));
1300
- realElm.append(innerNode);
1142
+ const fragment = parseAndSanitize(editor, realElmName, unescape(innerHtml));
1143
+ each$1(fragment.children(), child => realElm.append(child));
1301
1144
  }
1302
1145
  node.replace(realElm);
1303
1146
  }
1304
1147
  });
1305
1148
  });
1306
- editor.on('SetContent', function () {
1307
- editor.$('span.mce-preview-object').each(function (index, elm) {
1308
- var $elm = editor.$(elm);
1309
- if ($elm.find('span.mce-shim').length === 0) {
1310
- $elm.append('<span class="mce-shim"></span>');
1149
+ editor.on('SetContent', () => {
1150
+ const dom = editor.dom;
1151
+ each$1(dom.select('span.mce-preview-object'), elm => {
1152
+ if (dom.select('span.mce-shim', elm).length === 0) {
1153
+ dom.add(elm, 'span', { class: 'mce-shim' });
1311
1154
  }
1312
1155
  });
1313
1156
  });
1314
1157
  };
1315
1158
 
1316
- var setup = function (editor) {
1317
- editor.on('ResolveName', function (e) {
1318
- var name;
1159
+ const setup = editor => {
1160
+ editor.on('ResolveName', e => {
1161
+ let name;
1319
1162
  if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) {
1320
1163
  e.name = name;
1321
1164
  }
1322
1165
  });
1323
1166
  };
1324
1167
 
1325
- var register = function (editor) {
1326
- var onAction = function () {
1327
- return editor.execCommand('mceMedia');
1168
+ const onSetupEditable = editor => api => {
1169
+ const nodeChanged = () => {
1170
+ api.setEnabled(editor.selection.isEditable());
1171
+ };
1172
+ editor.on('NodeChange', nodeChanged);
1173
+ nodeChanged();
1174
+ return () => {
1175
+ editor.off('NodeChange', nodeChanged);
1328
1176
  };
1177
+ };
1178
+ const register = editor => {
1179
+ const onAction = () => editor.execCommand('mceMedia');
1329
1180
  editor.ui.registry.addToggleButton('media', {
1330
1181
  tooltip: 'Insert/edit media',
1331
1182
  icon: 'embed',
1332
- onAction: onAction,
1333
- onSetup: function (buttonApi) {
1334
- var selection = editor.selection;
1183
+ onAction,
1184
+ onSetup: buttonApi => {
1185
+ const selection = editor.selection;
1335
1186
  buttonApi.setActive(isMediaElement(selection.getNode()));
1336
- return selection.selectorChangedWithUnbind('img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]', buttonApi.setActive).unbind;
1187
+ const unbindSelectorChanged = selection.selectorChangedWithUnbind('img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]', buttonApi.setActive).unbind;
1188
+ const unbindEditable = onSetupEditable(editor)(buttonApi);
1189
+ return () => {
1190
+ unbindSelectorChanged();
1191
+ unbindEditable();
1192
+ };
1337
1193
  }
1338
1194
  });
1339
1195
  editor.ui.registry.addMenuItem('media', {
1340
1196
  icon: 'embed',
1341
1197
  text: 'Media...',
1342
- onAction: onAction
1198
+ onAction,
1199
+ onSetup: onSetupEditable(editor)
1343
1200
  });
1344
1201
  };
1345
1202
 
1346
- function Plugin () {
1347
- global$9.add('media', function (editor) {
1203
+ var Plugin = () => {
1204
+ global$6.add('media', editor => {
1205
+ register$2(editor);
1348
1206
  register$1(editor);
1349
1207
  register(editor);
1350
1208
  setup(editor);
@@ -1352,8 +1210,8 @@
1352
1210
  setup$2(editor);
1353
1211
  return get(editor);
1354
1212
  });
1355
- }
1213
+ };
1356
1214
 
1357
1215
  Plugin();
1358
1216
 
1359
- }());
1217
+ })();