@dangl/angular-material-shared 2.5.1-beta0012 → 2.6.0-beta0019

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,192 +1,205 @@
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
8
  var global$7 = tinymce.util.Tools.resolve('tinymce.PluginManager');
13
9
 
14
- var typeOf = function (x) {
15
- var t = typeof x;
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
+ }
17
+ };
18
+ const typeOf = x => {
19
+ const t = typeof x;
16
20
  if (x === null) {
17
21
  return 'null';
18
- } else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
22
+ } else if (t === 'object' && Array.isArray(x)) {
19
23
  return 'array';
20
- } 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))) {
21
25
  return 'string';
22
26
  } else {
23
27
  return t;
24
28
  }
25
29
  };
26
- var isType$1 = function (type) {
27
- return function (value) {
28
- return typeOf(value) === type;
29
- };
30
- };
31
- var isSimpleType = function (type) {
32
- return function (value) {
33
- return typeof value === type;
34
- };
35
- };
36
- var isString = isType$1('string');
37
- var isObject = isType$1('object');
38
- var isArray = isType$1('array');
39
- var isBoolean = isSimpleType('boolean');
40
- var isFunction = isSimpleType('function');
41
- var isNumber = isSimpleType('number');
30
+ const isType$1 = type => value => typeOf(value) === type;
31
+ const isSimpleType = type => value => typeof value === type;
32
+ const isString = isType$1('string');
33
+ const isObject = isType$1('object');
34
+ const isArray = isType$1('array');
35
+ const isBoolean = isSimpleType('boolean');
36
+ const isNullable = a => a === null || a === undefined;
37
+ const isNonNullable = a => !isNullable(a);
38
+ const isFunction = isSimpleType('function');
39
+ const isNumber = isSimpleType('number');
42
40
 
43
- var noop = function () {
41
+ const noop = () => {
44
42
  };
45
- var constant = function (value) {
46
- return function () {
43
+ const compose1 = (fbc, fab) => a => fbc(fab(a));
44
+ const constant = value => {
45
+ return () => {
47
46
  return value;
48
47
  };
49
48
  };
50
- var identity = function (x) {
51
- return x;
52
- };
53
- var tripleEquals = function (a, b) {
49
+ const tripleEquals = (a, b) => {
54
50
  return a === b;
55
51
  };
56
- var not = function (f) {
57
- return function (t) {
58
- return !f(t);
52
+ function curry(fn, ...initialArgs) {
53
+ return (...restArgs) => {
54
+ const all = initialArgs.concat(restArgs);
55
+ return fn.apply(null, all);
59
56
  };
60
- };
61
- var never = constant(false);
62
- var always = constant(true);
57
+ }
58
+ const not = f => t => !f(t);
59
+ const never = constant(false);
63
60
 
64
- var none = function () {
65
- return NONE;
66
- };
67
- var NONE = function () {
68
- var call = function (thunk) {
69
- return thunk();
70
- };
71
- var id = identity;
72
- var me = {
73
- fold: function (n, _s) {
74
- return n();
75
- },
76
- isSome: never,
77
- isNone: always,
78
- getOr: id,
79
- getOrThunk: call,
80
- getOrDie: function (msg) {
81
- throw new Error(msg || 'error: getOrDie called on none.');
82
- },
83
- getOrNull: constant(null),
84
- getOrUndefined: constant(undefined),
85
- or: id,
86
- orThunk: call,
87
- map: none,
88
- each: noop,
89
- bind: none,
90
- exists: never,
91
- forall: always,
92
- filter: function () {
93
- return none();
94
- },
95
- toArray: function () {
96
- return [];
97
- },
98
- toString: constant('none()')
99
- };
100
- return me;
101
- }();
102
- var some = function (a) {
103
- var constant_a = constant(a);
104
- var self = function () {
105
- return me;
106
- };
107
- var bind = function (f) {
108
- return f(a);
109
- };
110
- var me = {
111
- fold: function (n, s) {
112
- return s(a);
113
- },
114
- isSome: always,
115
- isNone: never,
116
- getOr: constant_a,
117
- getOrThunk: constant_a,
118
- getOrDie: constant_a,
119
- getOrNull: constant_a,
120
- getOrUndefined: constant_a,
121
- or: self,
122
- orThunk: self,
123
- map: function (f) {
124
- return some(f(a));
125
- },
126
- each: function (f) {
127
- f(a);
128
- },
129
- bind: bind,
130
- exists: bind,
131
- forall: bind,
132
- filter: function (f) {
133
- return f(a) ? me : NONE;
134
- },
135
- toArray: function () {
136
- return [a];
137
- },
138
- toString: function () {
139
- return 'some(' + a + ')';
61
+ class Optional {
62
+ constructor(tag, value) {
63
+ this.tag = tag;
64
+ this.value = value;
65
+ }
66
+ static some(value) {
67
+ return new Optional(true, value);
68
+ }
69
+ static none() {
70
+ return Optional.singletonNone;
71
+ }
72
+ fold(onNone, onSome) {
73
+ if (this.tag) {
74
+ return onSome(this.value);
75
+ } else {
76
+ return onNone();
140
77
  }
141
- };
142
- return me;
143
- };
144
- var from = function (value) {
145
- return value === null || value === undefined ? NONE : some(value);
146
- };
147
- var Optional = {
148
- some: some,
149
- none: none,
150
- from: from
78
+ }
79
+ isSome() {
80
+ return this.tag;
81
+ }
82
+ isNone() {
83
+ return !this.tag;
84
+ }
85
+ map(mapper) {
86
+ if (this.tag) {
87
+ return Optional.some(mapper(this.value));
88
+ } else {
89
+ return Optional.none();
90
+ }
91
+ }
92
+ bind(binder) {
93
+ if (this.tag) {
94
+ return binder(this.value);
95
+ } else {
96
+ return Optional.none();
97
+ }
98
+ }
99
+ exists(predicate) {
100
+ return this.tag && predicate(this.value);
101
+ }
102
+ forall(predicate) {
103
+ return !this.tag || predicate(this.value);
104
+ }
105
+ filter(predicate) {
106
+ if (!this.tag || predicate(this.value)) {
107
+ return this;
108
+ } else {
109
+ return Optional.none();
110
+ }
111
+ }
112
+ getOr(replacement) {
113
+ return this.tag ? this.value : replacement;
114
+ }
115
+ or(replacement) {
116
+ return this.tag ? this : replacement;
117
+ }
118
+ getOrThunk(thunk) {
119
+ return this.tag ? this.value : thunk();
120
+ }
121
+ orThunk(thunk) {
122
+ return this.tag ? this : thunk();
123
+ }
124
+ getOrDie(message) {
125
+ if (!this.tag) {
126
+ throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
127
+ } else {
128
+ return this.value;
129
+ }
130
+ }
131
+ static from(value) {
132
+ return isNonNullable(value) ? Optional.some(value) : Optional.none();
133
+ }
134
+ getOrNull() {
135
+ return this.tag ? this.value : null;
136
+ }
137
+ getOrUndefined() {
138
+ return this.value;
139
+ }
140
+ each(worker) {
141
+ if (this.tag) {
142
+ worker(this.value);
143
+ }
144
+ }
145
+ toArray() {
146
+ return this.tag ? [this.value] : [];
147
+ }
148
+ toString() {
149
+ return this.tag ? `some(${ this.value })` : 'none()';
150
+ }
151
+ }
152
+ Optional.singletonNone = new Optional(false);
153
+
154
+ const nativeSlice = Array.prototype.slice;
155
+ const nativeIndexOf = Array.prototype.indexOf;
156
+ const nativePush = Array.prototype.push;
157
+ const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
158
+ const contains$1 = (xs, x) => rawIndexOf(xs, x) > -1;
159
+ const exists = (xs, pred) => {
160
+ for (let i = 0, len = xs.length; i < len; i++) {
161
+ const x = xs[i];
162
+ if (pred(x, i)) {
163
+ return true;
164
+ }
165
+ }
166
+ return false;
151
167
  };
152
-
153
- var nativeSlice = Array.prototype.slice;
154
- var nativePush = Array.prototype.push;
155
- var map = function (xs, f) {
156
- var len = xs.length;
157
- var r = new Array(len);
158
- for (var i = 0; i < len; i++) {
159
- var x = xs[i];
168
+ const map = (xs, f) => {
169
+ const len = xs.length;
170
+ const r = new Array(len);
171
+ for (let i = 0; i < len; i++) {
172
+ const x = xs[i];
160
173
  r[i] = f(x, i);
161
174
  }
162
175
  return r;
163
176
  };
164
- var each$1 = function (xs, f) {
165
- for (var i = 0, len = xs.length; i < len; i++) {
166
- var x = xs[i];
177
+ const each$1 = (xs, f) => {
178
+ for (let i = 0, len = xs.length; i < len; i++) {
179
+ const x = xs[i];
167
180
  f(x, i);
168
181
  }
169
182
  };
170
- var filter$1 = function (xs, pred) {
171
- var r = [];
172
- for (var i = 0, len = xs.length; i < len; i++) {
173
- var x = xs[i];
183
+ const filter$1 = (xs, pred) => {
184
+ const r = [];
185
+ for (let i = 0, len = xs.length; i < len; i++) {
186
+ const x = xs[i];
174
187
  if (pred(x, i)) {
175
188
  r.push(x);
176
189
  }
177
190
  }
178
191
  return r;
179
192
  };
180
- var groupBy = function (xs, f) {
193
+ const groupBy = (xs, f) => {
181
194
  if (xs.length === 0) {
182
195
  return [];
183
196
  } else {
184
- var wasType = f(xs[0]);
185
- var r = [];
186
- var group = [];
187
- for (var i = 0, len = xs.length; i < len; i++) {
188
- var x = xs[i];
189
- var type = f(x);
197
+ let wasType = f(xs[0]);
198
+ const r = [];
199
+ let group = [];
200
+ for (let i = 0, len = xs.length; i < len; i++) {
201
+ const x = xs[i];
202
+ const type = f(x);
190
203
  if (type !== wasType) {
191
204
  r.push(group);
192
205
  group = [];
@@ -200,15 +213,15 @@
200
213
  return r;
201
214
  }
202
215
  };
203
- var foldl = function (xs, f, acc) {
204
- each$1(xs, function (x, i) {
216
+ const foldl = (xs, f, acc) => {
217
+ each$1(xs, (x, i) => {
205
218
  acc = f(acc, x, i);
206
219
  });
207
220
  return acc;
208
221
  };
209
- var findUntil = function (xs, pred, until) {
210
- for (var i = 0, len = xs.length; i < len; i++) {
211
- var x = xs[i];
222
+ const findUntil = (xs, pred, until) => {
223
+ for (let i = 0, len = xs.length; i < len; i++) {
224
+ const x = xs[i];
212
225
  if (pred(x, i)) {
213
226
  return Optional.some(x);
214
227
  } else if (until(x, i)) {
@@ -217,12 +230,12 @@
217
230
  }
218
231
  return Optional.none();
219
232
  };
220
- var find$1 = function (xs, pred) {
233
+ const find = (xs, pred) => {
221
234
  return findUntil(xs, pred, never);
222
235
  };
223
- var flatten = function (xs) {
224
- var r = [];
225
- for (var i = 0, len = xs.length; i < len; ++i) {
236
+ const flatten = xs => {
237
+ const r = [];
238
+ for (let i = 0, len = xs.length; i < len; ++i) {
226
239
  if (!isArray(xs[i])) {
227
240
  throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
228
241
  }
@@ -230,477 +243,79 @@
230
243
  }
231
244
  return r;
232
245
  };
233
- var bind = function (xs, f) {
234
- return flatten(map(xs, f));
235
- };
236
- var reverse = function (xs) {
237
- var r = nativeSlice.call(xs, 0);
246
+ const bind = (xs, f) => flatten(map(xs, f));
247
+ const reverse = xs => {
248
+ const r = nativeSlice.call(xs, 0);
238
249
  r.reverse();
239
250
  return r;
240
251
  };
241
- var get$1 = function (xs, i) {
242
- return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
243
- };
244
- var head = function (xs) {
245
- return get$1(xs, 0);
246
- };
247
- var last = function (xs) {
248
- return get$1(xs, xs.length - 1);
249
- };
250
- var findMap = function (arr, f) {
251
- for (var i = 0; i < arr.length; i++) {
252
- var r = f(arr[i], i);
253
- if (r.isSome()) {
254
- return r;
255
- }
256
- }
257
- return Optional.none();
258
- };
259
-
260
- var __assign = function () {
261
- __assign = Object.assign || function __assign(t) {
262
- for (var s, i = 1, n = arguments.length; i < n; i++) {
263
- s = arguments[i];
264
- for (var p in s)
265
- if (Object.prototype.hasOwnProperty.call(s, p))
266
- t[p] = s[p];
267
- }
268
- return t;
269
- };
270
- return __assign.apply(this, arguments);
271
- };
272
- function __spreadArray(to, from, pack) {
273
- if (pack || arguments.length === 2)
274
- for (var i = 0, l = from.length, ar; i < l; i++) {
275
- if (ar || !(i in from)) {
276
- if (!ar)
277
- ar = Array.prototype.slice.call(from, 0, i);
278
- ar[i] = from[i];
279
- }
280
- }
281
- return to.concat(ar || Array.prototype.slice.call(from));
282
- }
283
-
284
- var cached = function (f) {
285
- var called = false;
286
- var r;
287
- return function () {
288
- var args = [];
289
- for (var _i = 0; _i < arguments.length; _i++) {
290
- args[_i] = arguments[_i];
291
- }
292
- if (!called) {
293
- called = true;
294
- r = f.apply(null, args);
295
- }
296
- return r;
297
- };
298
- };
299
-
300
- var DeviceType = function (os, browser, userAgent, mediaMatch) {
301
- var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
302
- var isiPhone = os.isiOS() && !isiPad;
303
- var isMobile = os.isiOS() || os.isAndroid();
304
- var isTouch = isMobile || mediaMatch('(pointer:coarse)');
305
- var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
306
- var isPhone = isiPhone || isMobile && !isTablet;
307
- var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
308
- var isDesktop = !isPhone && !isTablet && !iOSwebview;
309
- return {
310
- isiPad: constant(isiPad),
311
- isiPhone: constant(isiPhone),
312
- isTablet: constant(isTablet),
313
- isPhone: constant(isPhone),
314
- isTouch: constant(isTouch),
315
- isAndroid: os.isAndroid,
316
- isiOS: os.isiOS,
317
- isWebView: constant(iOSwebview),
318
- isDesktop: constant(isDesktop)
319
- };
320
- };
321
-
322
- var firstMatch = function (regexes, s) {
323
- for (var i = 0; i < regexes.length; i++) {
324
- var x = regexes[i];
325
- if (x.test(s)) {
326
- return x;
327
- }
328
- }
329
- return undefined;
330
- };
331
- var find = function (regexes, agent) {
332
- var r = firstMatch(regexes, agent);
333
- if (!r) {
334
- return {
335
- major: 0,
336
- minor: 0
337
- };
338
- }
339
- var group = function (i) {
340
- return Number(agent.replace(r, '$' + i));
341
- };
342
- return nu$2(group(1), group(2));
343
- };
344
- var detect$3 = function (versionRegexes, agent) {
345
- var cleanedAgent = String(agent).toLowerCase();
346
- if (versionRegexes.length === 0) {
347
- return unknown$2();
348
- }
349
- return find(versionRegexes, cleanedAgent);
350
- };
351
- var unknown$2 = function () {
352
- return nu$2(0, 0);
353
- };
354
- var nu$2 = function (major, minor) {
355
- return {
356
- major: major,
357
- minor: minor
358
- };
359
- };
360
- var Version = {
361
- nu: nu$2,
362
- detect: detect$3,
363
- unknown: unknown$2
364
- };
365
-
366
- var detectBrowser$1 = function (browsers, userAgentData) {
367
- return findMap(userAgentData.brands, function (uaBrand) {
368
- var lcBrand = uaBrand.brand.toLowerCase();
369
- return find$1(browsers, function (browser) {
370
- var _a;
371
- return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
372
- }).map(function (info) {
373
- return {
374
- current: info.name,
375
- version: Version.nu(parseInt(uaBrand.version, 10), 0)
376
- };
377
- });
378
- });
379
- };
380
-
381
- var detect$2 = function (candidates, userAgent) {
382
- var agent = String(userAgent).toLowerCase();
383
- return find$1(candidates, function (candidate) {
384
- return candidate.search(agent);
385
- });
386
- };
387
- var detectBrowser = function (browsers, userAgent) {
388
- return detect$2(browsers, userAgent).map(function (browser) {
389
- var version = Version.detect(browser.versionRegexes, userAgent);
390
- return {
391
- current: browser.name,
392
- version: version
393
- };
394
- });
395
- };
396
- var detectOs = function (oses, userAgent) {
397
- return detect$2(oses, userAgent).map(function (os) {
398
- var version = Version.detect(os.versionRegexes, userAgent);
399
- return {
400
- current: os.name,
401
- version: version
402
- };
403
- });
404
- };
405
-
406
- var contains$1 = function (str, substr) {
407
- return str.indexOf(substr) !== -1;
408
- };
409
- var blank = function (r) {
410
- return function (s) {
411
- return s.replace(r, '');
412
- };
413
- };
414
- var trim = blank(/^\s+|\s+$/g);
415
- var isNotEmpty = function (s) {
416
- return s.length > 0;
417
- };
418
- var isEmpty$1 = function (s) {
419
- return !isNotEmpty(s);
420
- };
421
-
422
- var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
423
- var checkContains = function (target) {
424
- return function (uastring) {
425
- return contains$1(uastring, target);
426
- };
427
- };
428
- var browsers = [
429
- {
430
- name: 'Edge',
431
- versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
432
- search: function (uastring) {
433
- return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
434
- }
435
- },
436
- {
437
- name: 'Chrome',
438
- brand: 'Chromium',
439
- versionRegexes: [
440
- /.*?chrome\/([0-9]+)\.([0-9]+).*/,
441
- normalVersionRegex
442
- ],
443
- search: function (uastring) {
444
- return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
445
- }
446
- },
447
- {
448
- name: 'IE',
449
- versionRegexes: [
450
- /.*?msie\ ?([0-9]+)\.([0-9]+).*/,
451
- /.*?rv:([0-9]+)\.([0-9]+).*/
452
- ],
453
- search: function (uastring) {
454
- return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');
455
- }
456
- },
457
- {
458
- name: 'Opera',
459
- versionRegexes: [
460
- normalVersionRegex,
461
- /.*?opera\/([0-9]+)\.([0-9]+).*/
462
- ],
463
- search: checkContains('opera')
464
- },
465
- {
466
- name: 'Firefox',
467
- versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
468
- search: checkContains('firefox')
469
- },
470
- {
471
- name: 'Safari',
472
- versionRegexes: [
473
- normalVersionRegex,
474
- /.*?cpu os ([0-9]+)_([0-9]+).*/
475
- ],
476
- search: function (uastring) {
477
- return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
252
+ const get$1 = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
253
+ const head = xs => get$1(xs, 0);
254
+ const last = xs => get$1(xs, xs.length - 1);
255
+ const unique = (xs, comparator) => {
256
+ const r = [];
257
+ const isDuplicated = isFunction(comparator) ? x => exists(r, i => comparator(i, x)) : x => contains$1(r, x);
258
+ for (let i = 0, len = xs.length; i < len; i++) {
259
+ const x = xs[i];
260
+ if (!isDuplicated(x)) {
261
+ r.push(x);
478
262
  }
479
263
  }
480
- ];
481
- var oses = [
482
- {
483
- name: 'Windows',
484
- search: checkContains('win'),
485
- versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
486
- },
487
- {
488
- name: 'iOS',
489
- search: function (uastring) {
490
- return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');
491
- },
492
- versionRegexes: [
493
- /.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
494
- /.*cpu os ([0-9]+)_([0-9]+).*/,
495
- /.*cpu iphone os ([0-9]+)_([0-9]+).*/
496
- ]
497
- },
498
- {
499
- name: 'Android',
500
- search: checkContains('android'),
501
- versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
502
- },
503
- {
504
- name: 'OSX',
505
- search: checkContains('mac os x'),
506
- versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
507
- },
508
- {
509
- name: 'Linux',
510
- search: checkContains('linux'),
511
- versionRegexes: []
512
- },
513
- {
514
- name: 'Solaris',
515
- search: checkContains('sunos'),
516
- versionRegexes: []
517
- },
518
- {
519
- name: 'FreeBSD',
520
- search: checkContains('freebsd'),
521
- versionRegexes: []
522
- },
523
- {
524
- name: 'ChromeOS',
525
- search: checkContains('cros'),
526
- versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
527
- }
528
- ];
529
- var PlatformInfo = {
530
- browsers: constant(browsers),
531
- oses: constant(oses)
532
- };
533
-
534
- var edge = 'Edge';
535
- var chrome = 'Chrome';
536
- var ie = 'IE';
537
- var opera = 'Opera';
538
- var firefox = 'Firefox';
539
- var safari = 'Safari';
540
- var unknown$1 = function () {
541
- return nu$1({
542
- current: undefined,
543
- version: Version.unknown()
544
- });
545
- };
546
- var nu$1 = function (info) {
547
- var current = info.current;
548
- var version = info.version;
549
- var isBrowser = function (name) {
550
- return function () {
551
- return current === name;
552
- };
553
- };
554
- return {
555
- current: current,
556
- version: version,
557
- isEdge: isBrowser(edge),
558
- isChrome: isBrowser(chrome),
559
- isIE: isBrowser(ie),
560
- isOpera: isBrowser(opera),
561
- isFirefox: isBrowser(firefox),
562
- isSafari: isBrowser(safari)
563
- };
564
- };
565
- var Browser = {
566
- unknown: unknown$1,
567
- nu: nu$1,
568
- edge: constant(edge),
569
- chrome: constant(chrome),
570
- ie: constant(ie),
571
- opera: constant(opera),
572
- firefox: constant(firefox),
573
- safari: constant(safari)
574
- };
575
-
576
- var windows = 'Windows';
577
- var ios = 'iOS';
578
- var android = 'Android';
579
- var linux = 'Linux';
580
- var osx = 'OSX';
581
- var solaris = 'Solaris';
582
- var freebsd = 'FreeBSD';
583
- var chromeos = 'ChromeOS';
584
- var unknown = function () {
585
- return nu({
586
- current: undefined,
587
- version: Version.unknown()
588
- });
589
- };
590
- var nu = function (info) {
591
- var current = info.current;
592
- var version = info.version;
593
- var isOS = function (name) {
594
- return function () {
595
- return current === name;
596
- };
597
- };
598
- return {
599
- current: current,
600
- version: version,
601
- isWindows: isOS(windows),
602
- isiOS: isOS(ios),
603
- isAndroid: isOS(android),
604
- isOSX: isOS(osx),
605
- isLinux: isOS(linux),
606
- isSolaris: isOS(solaris),
607
- isFreeBSD: isOS(freebsd),
608
- isChromeOS: isOS(chromeos)
609
- };
610
- };
611
- var OperatingSystem = {
612
- unknown: unknown,
613
- nu: nu,
614
- windows: constant(windows),
615
- ios: constant(ios),
616
- android: constant(android),
617
- linux: constant(linux),
618
- osx: constant(osx),
619
- solaris: constant(solaris),
620
- freebsd: constant(freebsd),
621
- chromeos: constant(chromeos)
622
- };
623
-
624
- var detect$1 = function (userAgent, userAgentDataOpt, mediaMatch) {
625
- var browsers = PlatformInfo.browsers();
626
- var oses = PlatformInfo.oses();
627
- var browser = userAgentDataOpt.bind(function (userAgentData) {
628
- return detectBrowser$1(browsers, userAgentData);
629
- }).orThunk(function () {
630
- return detectBrowser(browsers, userAgent);
631
- }).fold(Browser.unknown, Browser.nu);
632
- var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
633
- var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
634
- return {
635
- browser: browser,
636
- os: os,
637
- deviceType: deviceType
638
- };
639
- };
640
- var PlatformDetection = { detect: detect$1 };
641
-
642
- var mediaMatch = function (query) {
643
- return window.matchMedia(query).matches;
644
- };
645
- var platform = cached(function () {
646
- return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
647
- });
648
- var detect = function () {
649
- return platform();
264
+ return r;
650
265
  };
651
266
 
652
- var compareDocumentPosition = function (a, b, match) {
653
- return (a.compareDocumentPosition(b) & match) !== 0;
654
- };
655
- var documentPositionContainedBy = function (a, b) {
656
- return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);
657
- };
267
+ const is$2 = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));
268
+ const equals = (lhs, rhs, comparator = tripleEquals) => lift2(lhs, rhs, comparator).getOr(lhs.isNone() && rhs.isNone());
269
+ const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
658
270
 
659
- var ELEMENT = 1;
271
+ const COMMENT = 8;
272
+ const DOCUMENT = 9;
273
+ const DOCUMENT_FRAGMENT = 11;
274
+ const ELEMENT = 1;
275
+ const TEXT = 3;
660
276
 
661
- var fromHtml = function (html, scope) {
662
- var doc = scope || document;
663
- var div = doc.createElement('div');
277
+ const fromHtml = (html, scope) => {
278
+ const doc = scope || document;
279
+ const div = doc.createElement('div');
664
280
  div.innerHTML = html;
665
281
  if (!div.hasChildNodes() || div.childNodes.length > 1) {
666
- console.error('HTML does not have a single root node', html);
667
- throw new Error('HTML must have a single root node');
282
+ const message = 'HTML does not have a single root node';
283
+ console.error(message, html);
284
+ throw new Error(message);
668
285
  }
669
- return fromDom(div.childNodes[0]);
286
+ return fromDom$1(div.childNodes[0]);
670
287
  };
671
- var fromTag = function (tag, scope) {
672
- var doc = scope || document;
673
- var node = doc.createElement(tag);
674
- return fromDom(node);
288
+ const fromTag = (tag, scope) => {
289
+ const doc = scope || document;
290
+ const node = doc.createElement(tag);
291
+ return fromDom$1(node);
675
292
  };
676
- var fromText = function (text, scope) {
677
- var doc = scope || document;
678
- var node = doc.createTextNode(text);
679
- return fromDom(node);
293
+ const fromText = (text, scope) => {
294
+ const doc = scope || document;
295
+ const node = doc.createTextNode(text);
296
+ return fromDom$1(node);
680
297
  };
681
- var fromDom = function (node) {
298
+ const fromDom$1 = node => {
682
299
  if (node === null || node === undefined) {
683
300
  throw new Error('Node cannot be null or undefined');
684
301
  }
685
302
  return { dom: node };
686
303
  };
687
- var fromPoint = function (docElm, x, y) {
688
- return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
689
- };
690
- var SugarElement = {
691
- fromHtml: fromHtml,
692
- fromTag: fromTag,
693
- fromText: fromText,
694
- fromDom: fromDom,
695
- fromPoint: fromPoint
304
+ const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1);
305
+ const SugarElement = {
306
+ fromHtml,
307
+ fromTag,
308
+ fromText,
309
+ fromDom: fromDom$1,
310
+ fromPoint
696
311
  };
697
312
 
698
- var is$2 = function (element, selector) {
699
- var dom = element.dom;
313
+ const is$1 = (element, selector) => {
314
+ const dom = element.dom;
700
315
  if (dom.nodeType !== ELEMENT) {
701
316
  return false;
702
317
  } else {
703
- var elem = dom;
318
+ const elem = dom;
704
319
  if (elem.matches !== undefined) {
705
320
  return elem.matches(selector);
706
321
  } else if (elem.msMatchesSelector !== undefined) {
@@ -715,158 +330,253 @@
715
330
  }
716
331
  };
717
332
 
718
- var eq = function (e1, e2) {
719
- return e1.dom === e2.dom;
720
- };
721
- var regularContains = function (e1, e2) {
722
- var d1 = e1.dom;
723
- var d2 = e2.dom;
333
+ const eq = (e1, e2) => e1.dom === e2.dom;
334
+ const contains = (e1, e2) => {
335
+ const d1 = e1.dom;
336
+ const d2 = e2.dom;
724
337
  return d1 === d2 ? false : d1.contains(d2);
725
338
  };
726
- var ieContains = function (e1, e2) {
727
- return documentPositionContainedBy(e1.dom, e2.dom);
728
- };
729
- var contains = function (e1, e2) {
730
- return detect().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
731
- };
732
- var is$1 = is$2;
733
-
734
- var global$6 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
339
+ const is = is$1;
735
340
 
736
- var global$5 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
341
+ const Global = typeof window !== 'undefined' ? window : Function('return this;')();
737
342
 
738
- var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK');
739
-
740
- var keys = Object.keys;
741
- var each = function (obj, f) {
742
- var props = keys(obj);
743
- for (var k = 0, len = props.length; k < len; k++) {
744
- var i = props[k];
745
- var x = obj[i];
746
- f(x, i);
343
+ const path = (parts, scope) => {
344
+ let o = scope !== undefined && scope !== null ? scope : Global;
345
+ for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
346
+ o = o[parts[i]];
747
347
  }
348
+ return o;
748
349
  };
749
- var objAcc = function (r) {
750
- return function (x, i) {
751
- r[i] = x;
752
- };
350
+ const resolve = (p, scope) => {
351
+ const parts = p.split('.');
352
+ return path(parts, scope);
753
353
  };
754
- var internalFilter = function (obj, pred, onTrue, onFalse) {
755
- var r = {};
756
- each(obj, function (x, i) {
757
- (pred(x, i) ? onTrue : onFalse)(x, i);
758
- });
759
- return r;
354
+
355
+ const unsafe = (name, scope) => {
356
+ return resolve(name, scope);
760
357
  };
761
- var filter = function (obj, pred) {
762
- var t = {};
763
- internalFilter(obj, pred, objAcc(t), noop);
764
- return t;
358
+ const getOrDie = (name, scope) => {
359
+ const actual = unsafe(name, scope);
360
+ if (actual === undefined || actual === null) {
361
+ throw new Error(name + ' not available on this browser');
362
+ }
363
+ return actual;
765
364
  };
766
365
 
767
- typeof window !== 'undefined' ? window : Function('return this;')();
366
+ const getPrototypeOf = Object.getPrototypeOf;
367
+ const sandHTMLElement = scope => {
368
+ return getOrDie('HTMLElement', scope);
369
+ };
370
+ const isPrototypeOf = x => {
371
+ const scope = resolve('ownerDocument.defaultView', x);
372
+ return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
373
+ };
768
374
 
769
- var name = function (element) {
770
- var r = element.dom.nodeName;
375
+ const name = element => {
376
+ const r = element.dom.nodeName;
771
377
  return r.toLowerCase();
772
378
  };
773
- var type = function (element) {
774
- return element.dom.nodeType;
379
+ const type = element => element.dom.nodeType;
380
+ const isType = t => element => type(element) === t;
381
+ const isComment = element => type(element) === COMMENT || name(element) === '#comment';
382
+ const isHTMLElement = element => isElement$1(element) && isPrototypeOf(element.dom);
383
+ const isElement$1 = isType(ELEMENT);
384
+ const isText = isType(TEXT);
385
+ const isDocument = isType(DOCUMENT);
386
+ const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
387
+ const isTag = tag => e => isElement$1(e) && name(e) === tag;
388
+
389
+ const owner = element => SugarElement.fromDom(element.dom.ownerDocument);
390
+ const documentOrOwner = dos => isDocument(dos) ? dos : owner(dos);
391
+ const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
392
+ const parentElement = element => Optional.from(element.dom.parentElement).map(SugarElement.fromDom);
393
+ const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
394
+ const children = element => map(element.dom.childNodes, SugarElement.fromDom);
395
+ const child = (element, index) => {
396
+ const cs = element.dom.childNodes;
397
+ return Optional.from(cs[index]).map(SugarElement.fromDom);
775
398
  };
776
- var isType = function (t) {
777
- return function (element) {
778
- return type(element) === t;
779
- };
399
+ const firstChild = element => child(element, 0);
400
+ const lastChild = element => child(element, element.dom.childNodes.length - 1);
401
+
402
+ const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
403
+ const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
404
+ const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;
405
+ const getShadowRoot = e => {
406
+ const r = getRootNode(e);
407
+ return isShadowRoot(r) ? Optional.some(r) : Optional.none();
780
408
  };
781
- var isElement = isType(ELEMENT);
782
- var isTag = function (tag) {
783
- return function (e) {
784
- return isElement(e) && name(e) === tag;
785
- };
409
+ const getShadowHost = e => SugarElement.fromDom(e.dom.host);
410
+
411
+ const inBody = element => {
412
+ const dom = isText(element) ? element.dom.parentNode : element.dom;
413
+ if (dom === undefined || dom === null || dom.ownerDocument === null) {
414
+ return false;
415
+ }
416
+ const doc = dom.ownerDocument;
417
+ return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
786
418
  };
787
419
 
788
- var rawSet = function (dom, key, value) {
789
- if (isString(value) || isBoolean(value) || isNumber(value)) {
790
- dom.setAttribute(key, value + '');
420
+ var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
421
+ if (is(scope, a)) {
422
+ return Optional.some(scope);
423
+ } else if (isFunction(isRoot) && isRoot(scope)) {
424
+ return Optional.none();
791
425
  } else {
792
- console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
793
- throw new Error('Attribute value was not simple');
426
+ return ancestor(scope, a, isRoot);
794
427
  }
795
428
  };
796
- var setAll = function (element, attrs) {
797
- var dom = element.dom;
798
- each(attrs, function (v, k) {
799
- rawSet(dom, k, v);
800
- });
801
- };
802
- var clone$1 = function (element) {
803
- return foldl(element.dom.attributes, function (acc, attr) {
804
- acc[attr.name] = attr.value;
805
- return acc;
806
- }, {});
807
- };
808
429
 
809
- var parent = function (element) {
810
- return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
811
- };
812
- var children = function (element) {
813
- return map(element.dom.childNodes, SugarElement.fromDom);
430
+ const ancestor$3 = (scope, predicate, isRoot) => {
431
+ let element = scope.dom;
432
+ const stop = isFunction(isRoot) ? isRoot : never;
433
+ while (element.parentNode) {
434
+ element = element.parentNode;
435
+ const el = SugarElement.fromDom(element);
436
+ if (predicate(el)) {
437
+ return Optional.some(el);
438
+ } else if (stop(el)) {
439
+ break;
440
+ }
441
+ }
442
+ return Optional.none();
814
443
  };
815
- var child = function (element, index) {
816
- var cs = element.dom.childNodes;
817
- return Optional.from(cs[index]).map(SugarElement.fromDom);
444
+ const closest$2 = (scope, predicate, isRoot) => {
445
+ const is = (s, test) => test(s);
446
+ return ClosestOrAncestor(is, ancestor$3, scope, predicate, isRoot);
818
447
  };
819
- var firstChild = function (element) {
820
- return child(element, 0);
448
+
449
+ const ancestor$2 = (scope, selector, isRoot) => ancestor$3(scope, e => is$1(e, selector), isRoot);
450
+ const closest$1 = (scope, selector, isRoot) => {
451
+ const is = (element, selector) => is$1(element, selector);
452
+ return ClosestOrAncestor(is, ancestor$2, scope, selector, isRoot);
821
453
  };
822
- var lastChild = function (element) {
823
- return child(element, element.dom.childNodes.length - 1);
454
+
455
+ const closest = target => closest$1(target, '[contenteditable]');
456
+ const isEditable = (element, assumeEditable = false) => {
457
+ if (inBody(element)) {
458
+ return element.dom.isContentEditable;
459
+ } else {
460
+ return closest(element).fold(constant(assumeEditable), editable => getRaw(editable) === 'true');
461
+ }
824
462
  };
463
+ const getRaw = element => element.dom.contentEditable;
825
464
 
826
- var before$1 = function (marker, element) {
827
- var parent$1 = parent(marker);
828
- parent$1.each(function (v) {
465
+ const before$1 = (marker, element) => {
466
+ const parent$1 = parent(marker);
467
+ parent$1.each(v => {
829
468
  v.dom.insertBefore(element.dom, marker.dom);
830
469
  });
831
470
  };
832
- var append$1 = function (parent, element) {
471
+ const after = (marker, element) => {
472
+ const sibling = nextSibling(marker);
473
+ sibling.fold(() => {
474
+ const parent$1 = parent(marker);
475
+ parent$1.each(v => {
476
+ append$1(v, element);
477
+ });
478
+ }, v => {
479
+ before$1(v, element);
480
+ });
481
+ };
482
+ const prepend = (parent, element) => {
483
+ const firstChild$1 = firstChild(parent);
484
+ firstChild$1.fold(() => {
485
+ append$1(parent, element);
486
+ }, v => {
487
+ parent.dom.insertBefore(element.dom, v.dom);
488
+ });
489
+ };
490
+ const append$1 = (parent, element) => {
833
491
  parent.dom.appendChild(element.dom);
834
492
  };
835
493
 
836
- var before = function (marker, elements) {
837
- each$1(elements, function (x) {
494
+ const before = (marker, elements) => {
495
+ each$1(elements, x => {
838
496
  before$1(marker, x);
839
497
  });
840
498
  };
841
- var append = function (parent, elements) {
842
- each$1(elements, function (x) {
499
+ const append = (parent, elements) => {
500
+ each$1(elements, x => {
843
501
  append$1(parent, x);
844
502
  });
845
503
  };
846
504
 
847
- var remove = function (element) {
848
- var dom = element.dom;
505
+ const empty = element => {
506
+ element.dom.textContent = '';
507
+ each$1(children(element), rogue => {
508
+ remove(rogue);
509
+ });
510
+ };
511
+ const remove = element => {
512
+ const dom = element.dom;
849
513
  if (dom.parentNode !== null) {
850
514
  dom.parentNode.removeChild(dom);
851
515
  }
852
516
  };
853
517
 
854
- var clone = function (original, isDeep) {
855
- return SugarElement.fromDom(original.dom.cloneNode(isDeep));
518
+ var global$6 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
519
+
520
+ var global$5 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
521
+
522
+ var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK');
523
+
524
+ const fromDom = nodes => map(nodes, SugarElement.fromDom);
525
+
526
+ const keys = Object.keys;
527
+ const each = (obj, f) => {
528
+ const props = keys(obj);
529
+ for (let k = 0, len = props.length; k < len; k++) {
530
+ const i = props[k];
531
+ const x = obj[i];
532
+ f(x, i);
533
+ }
534
+ };
535
+ const objAcc = r => (x, i) => {
536
+ r[i] = x;
537
+ };
538
+ const internalFilter = (obj, pred, onTrue, onFalse) => {
539
+ each(obj, (x, i) => {
540
+ (pred(x, i) ? onTrue : onFalse)(x, i);
541
+ });
542
+ };
543
+ const filter = (obj, pred) => {
544
+ const t = {};
545
+ internalFilter(obj, pred, objAcc(t), noop);
546
+ return t;
547
+ };
548
+
549
+ const rawSet = (dom, key, value) => {
550
+ if (isString(value) || isBoolean(value) || isNumber(value)) {
551
+ dom.setAttribute(key, value + '');
552
+ } else {
553
+ console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
554
+ throw new Error('Attribute value was not simple');
555
+ }
856
556
  };
857
- var deep = function (original) {
858
- return clone(original, true);
557
+ const setAll = (element, attrs) => {
558
+ const dom = element.dom;
559
+ each(attrs, (v, k) => {
560
+ rawSet(dom, k, v);
561
+ });
859
562
  };
860
- var shallowAs = function (original, tag) {
861
- var nu = SugarElement.fromTag(tag);
862
- var attributes = clone$1(original);
563
+ const clone$1 = element => foldl(element.dom.attributes, (acc, attr) => {
564
+ acc[attr.name] = attr.value;
565
+ return acc;
566
+ }, {});
567
+
568
+ const clone = (original, isDeep) => SugarElement.fromDom(original.dom.cloneNode(isDeep));
569
+ const deep = original => clone(original, true);
570
+ const shallowAs = (original, tag) => {
571
+ const nu = SugarElement.fromTag(tag);
572
+ const attributes = clone$1(original);
863
573
  setAll(nu, attributes);
864
574
  return nu;
865
575
  };
866
- var mutate = function (original, tag) {
867
- var nu = shallowAs(original, tag);
868
- before$1(original, nu);
869
- var children$1 = children(original);
576
+ const mutate = (original, tag) => {
577
+ const nu = shallowAs(original, tag);
578
+ after(original, nu);
579
+ const children$1 = children(original);
870
580
  append(nu, children$1);
871
581
  remove(original);
872
582
  return nu;
@@ -876,131 +586,104 @@
876
586
 
877
587
  var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
878
588
 
879
- var matchNodeName = function (name) {
880
- return function (node) {
881
- return node && node.nodeName.toLowerCase() === name;
882
- };
883
- };
884
- var matchNodeNames = function (regex) {
885
- return function (node) {
886
- return node && regex.test(node.nodeName);
887
- };
888
- };
889
- var isTextNode = function (node) {
890
- return node && node.nodeType === 3;
891
- };
892
- var isListNode = matchNodeNames(/^(OL|UL|DL)$/);
893
- var isOlUlNode = matchNodeNames(/^(OL|UL)$/);
894
- var isOlNode = matchNodeName('ol');
895
- var isListItemNode = matchNodeNames(/^(LI|DT|DD)$/);
896
- var isDlItemNode = matchNodeNames(/^(DT|DD)$/);
897
- var isTableCellNode = matchNodeNames(/^(TH|TD)$/);
898
- var isBr = matchNodeName('br');
899
- var isFirstChild = function (node) {
900
- return node.parentNode.firstChild === node;
901
- };
902
- var isTextBlock = function (editor, node) {
903
- return node && !!editor.schema.getTextBlockElements()[node.nodeName];
904
- };
905
- var isBlock = function (node, blockElements) {
906
- return node && node.nodeName in blockElements;
907
- };
908
- var isBogusBr = function (dom, node) {
589
+ const matchNodeName = name => node => isNonNullable(node) && node.nodeName.toLowerCase() === name;
590
+ const matchNodeNames = regex => node => isNonNullable(node) && regex.test(node.nodeName);
591
+ const isTextNode$1 = node => isNonNullable(node) && node.nodeType === 3;
592
+ const isElement = node => isNonNullable(node) && node.nodeType === 1;
593
+ const isListNode = matchNodeNames(/^(OL|UL|DL)$/);
594
+ const isOlUlNode = matchNodeNames(/^(OL|UL)$/);
595
+ const isOlNode = matchNodeName('ol');
596
+ const isListItemNode = matchNodeNames(/^(LI|DT|DD)$/);
597
+ const isDlItemNode = matchNodeNames(/^(DT|DD)$/);
598
+ const isTableCellNode = matchNodeNames(/^(TH|TD)$/);
599
+ const isBr = matchNodeName('br');
600
+ const isFirstChild = node => {
601
+ var _a;
602
+ return ((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.firstChild) === node;
603
+ };
604
+ const isTextBlock = (editor, node) => isNonNullable(node) && node.nodeName in editor.schema.getTextBlockElements();
605
+ const isBlock = (node, blockElements) => isNonNullable(node) && node.nodeName in blockElements;
606
+ const isVoid = (editor, node) => isNonNullable(node) && node.nodeName in editor.schema.getVoidElements();
607
+ const isBogusBr = (dom, node) => {
909
608
  if (!isBr(node)) {
910
609
  return false;
911
610
  }
912
611
  return dom.isBlock(node.nextSibling) && !isBr(node.previousSibling);
913
612
  };
914
- var isEmpty = function (dom, elm, keepBookmarks) {
915
- var empty = dom.isEmpty(elm);
613
+ const isEmpty$2 = (dom, elm, keepBookmarks) => {
614
+ const empty = dom.isEmpty(elm);
916
615
  if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) {
917
616
  return false;
918
617
  }
919
618
  return empty;
920
619
  };
921
- var isChildOfBody = function (dom, elm) {
922
- return dom.isChildOf(elm, dom.getRoot());
923
- };
620
+ const isChildOfBody = (dom, elm) => dom.isChildOf(elm, dom.getRoot());
924
621
 
925
- var shouldIndentOnTab = function (editor) {
926
- return editor.getParam('lists_indent_on_tab', true);
927
- };
928
- var getForcedRootBlock = function (editor) {
929
- var block = editor.getParam('forced_root_block', 'p');
930
- if (block === false) {
931
- return '';
932
- } else if (block === true) {
933
- return 'p';
934
- } else {
935
- return block;
936
- }
937
- };
938
- var getForcedRootBlockAttrs = function (editor) {
939
- return editor.getParam('forced_root_block_attrs', {});
622
+ const option = name => editor => editor.options.get(name);
623
+ const register$3 = editor => {
624
+ const registerOption = editor.options.register;
625
+ registerOption('lists_indent_on_tab', {
626
+ processor: 'boolean',
627
+ default: true
628
+ });
940
629
  };
941
-
942
- var createTextBlock = function (editor, contentNode) {
943
- var dom = editor.dom;
944
- var blockElements = editor.schema.getBlockElements();
945
- var fragment = dom.createFragment();
946
- var blockName = getForcedRootBlock(editor);
947
- var node, textBlock, hasContentNode;
948
- if (blockName) {
949
- textBlock = dom.create(blockName);
950
- if (textBlock.tagName === blockName.toUpperCase()) {
951
- dom.setAttribs(textBlock, getForcedRootBlockAttrs(editor));
630
+ const shouldIndentOnTab = option('lists_indent_on_tab');
631
+ const getForcedRootBlock = option('forced_root_block');
632
+ const getForcedRootBlockAttrs = option('forced_root_block_attrs');
633
+
634
+ const createTextBlock = (editor, contentNode) => {
635
+ const dom = editor.dom;
636
+ const blockElements = editor.schema.getBlockElements();
637
+ const fragment = dom.createFragment();
638
+ const blockName = getForcedRootBlock(editor);
639
+ const blockAttrs = getForcedRootBlockAttrs(editor);
640
+ let node;
641
+ let textBlock;
642
+ let hasContentNode = false;
643
+ textBlock = dom.create(blockName, blockAttrs);
644
+ if (!isBlock(contentNode.firstChild, blockElements)) {
645
+ fragment.appendChild(textBlock);
646
+ }
647
+ while (node = contentNode.firstChild) {
648
+ const nodeName = node.nodeName;
649
+ if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
650
+ hasContentNode = true;
952
651
  }
953
- if (!isBlock(contentNode.firstChild, blockElements)) {
954
- fragment.appendChild(textBlock);
955
- }
956
- }
957
- if (contentNode) {
958
- while (node = contentNode.firstChild) {
959
- var nodeName = node.nodeName;
960
- if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
961
- hasContentNode = true;
962
- }
963
- if (isBlock(node, blockElements)) {
964
- fragment.appendChild(node);
965
- textBlock = null;
966
- } else {
967
- if (blockName) {
968
- if (!textBlock) {
969
- textBlock = dom.create(blockName);
970
- fragment.appendChild(textBlock);
971
- }
972
- textBlock.appendChild(node);
973
- } else {
974
- fragment.appendChild(node);
975
- }
652
+ if (isBlock(node, blockElements)) {
653
+ fragment.appendChild(node);
654
+ textBlock = null;
655
+ } else {
656
+ if (!textBlock) {
657
+ textBlock = dom.create(blockName, blockAttrs);
658
+ fragment.appendChild(textBlock);
976
659
  }
660
+ textBlock.appendChild(node);
977
661
  }
978
662
  }
979
- if (!blockName) {
980
- fragment.appendChild(dom.create('br'));
981
- } else {
982
- if (!hasContentNode) {
983
- textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
984
- }
663
+ if (!hasContentNode && textBlock) {
664
+ textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
985
665
  }
986
666
  return fragment;
987
667
  };
988
668
 
989
- var DOM$2 = global$3.DOM;
990
- var splitList = function (editor, list, li) {
991
- var removeAndKeepBookmarks = function (targetNode) {
992
- global$2.each(bookmarks, function (node) {
993
- targetNode.parentNode.insertBefore(node, li.parentNode);
994
- });
669
+ const DOM$2 = global$3.DOM;
670
+ const splitList = (editor, list, li) => {
671
+ const removeAndKeepBookmarks = targetNode => {
672
+ const parent = targetNode.parentNode;
673
+ if (parent) {
674
+ global$2.each(bookmarks, node => {
675
+ parent.insertBefore(node, li.parentNode);
676
+ });
677
+ }
995
678
  DOM$2.remove(targetNode);
996
679
  };
997
- var bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', list);
998
- var newBlock = createTextBlock(editor, li);
999
- var tmpRng = DOM$2.createRng();
680
+ const bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', list);
681
+ const newBlock = createTextBlock(editor, li);
682
+ const tmpRng = DOM$2.createRng();
1000
683
  tmpRng.setStartAfter(li);
1001
684
  tmpRng.setEndAfter(list);
1002
- var fragment = tmpRng.extractContents();
1003
- for (var node = fragment.firstChild; node; node = node.firstChild) {
685
+ const fragment = tmpRng.extractContents();
686
+ for (let node = fragment.firstChild; node; node = node.firstChild) {
1004
687
  if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
1005
688
  DOM$2.remove(node);
1006
689
  break;
@@ -1010,173 +693,189 @@
1010
693
  DOM$2.insertAfter(fragment, list);
1011
694
  }
1012
695
  DOM$2.insertAfter(newBlock, list);
1013
- if (isEmpty(editor.dom, li.parentNode)) {
1014
- removeAndKeepBookmarks(li.parentNode);
696
+ const parent = li.parentElement;
697
+ if (parent && isEmpty$2(editor.dom, parent)) {
698
+ removeAndKeepBookmarks(parent);
1015
699
  }
1016
700
  DOM$2.remove(li);
1017
- if (isEmpty(editor.dom, list)) {
701
+ if (isEmpty$2(editor.dom, list)) {
1018
702
  DOM$2.remove(list);
1019
703
  }
1020
704
  };
1021
705
 
1022
- var isDescriptionDetail = isTag('dd');
1023
- var isDescriptionTerm = isTag('dt');
1024
- var outdentDlItem = function (editor, item) {
706
+ const isDescriptionDetail = isTag('dd');
707
+ const isDescriptionTerm = isTag('dt');
708
+ const outdentDlItem = (editor, item) => {
1025
709
  if (isDescriptionDetail(item)) {
1026
710
  mutate(item, 'dt');
1027
711
  } else if (isDescriptionTerm(item)) {
1028
- parent(item).each(function (dl) {
1029
- return splitList(editor, dl.dom, item.dom);
1030
- });
712
+ parentElement(item).each(dl => splitList(editor, dl.dom, item.dom));
1031
713
  }
1032
714
  };
1033
- var indentDlItem = function (item) {
715
+ const indentDlItem = item => {
1034
716
  if (isDescriptionTerm(item)) {
1035
717
  mutate(item, 'dd');
1036
718
  }
1037
719
  };
1038
- var dlIndentation = function (editor, indentation, dlItems) {
720
+ const dlIndentation = (editor, indentation, dlItems) => {
1039
721
  if (indentation === 'Indent') {
1040
722
  each$1(dlItems, indentDlItem);
1041
723
  } else {
1042
- each$1(dlItems, function (item) {
1043
- return outdentDlItem(editor, item);
1044
- });
724
+ each$1(dlItems, item => outdentDlItem(editor, item));
1045
725
  }
1046
726
  };
1047
727
 
1048
- var getNormalizedPoint = function (container, offset) {
1049
- if (isTextNode(container)) {
728
+ const getNormalizedPoint = (container, offset) => {
729
+ if (isTextNode$1(container)) {
1050
730
  return {
1051
- container: container,
1052
- offset: offset
731
+ container,
732
+ offset
1053
733
  };
1054
734
  }
1055
- var node = global$6.getNode(container, offset);
1056
- if (isTextNode(node)) {
735
+ const node = global$6.getNode(container, offset);
736
+ if (isTextNode$1(node)) {
1057
737
  return {
1058
738
  container: node,
1059
739
  offset: offset >= container.childNodes.length ? node.data.length : 0
1060
740
  };
1061
- } else if (node.previousSibling && isTextNode(node.previousSibling)) {
741
+ } else if (node.previousSibling && isTextNode$1(node.previousSibling)) {
1062
742
  return {
1063
743
  container: node.previousSibling,
1064
744
  offset: node.previousSibling.data.length
1065
745
  };
1066
- } else if (node.nextSibling && isTextNode(node.nextSibling)) {
746
+ } else if (node.nextSibling && isTextNode$1(node.nextSibling)) {
1067
747
  return {
1068
748
  container: node.nextSibling,
1069
749
  offset: 0
1070
750
  };
1071
751
  }
1072
752
  return {
1073
- container: container,
1074
- offset: offset
753
+ container,
754
+ offset
1075
755
  };
1076
756
  };
1077
- var normalizeRange = function (rng) {
1078
- var outRng = rng.cloneRange();
1079
- var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
757
+ const normalizeRange = rng => {
758
+ const outRng = rng.cloneRange();
759
+ const rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
1080
760
  outRng.setStart(rangeStart.container, rangeStart.offset);
1081
- var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
761
+ const rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
1082
762
  outRng.setEnd(rangeEnd.container, rangeEnd.offset);
1083
763
  return outRng;
1084
764
  };
1085
765
 
1086
- var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
1087
-
1088
- var getParentList = function (editor, node) {
1089
- var selectionStart = node || editor.selection.getStart(true);
1090
- return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart));
1091
- };
1092
- var isParentListSelected = function (parentList, selectedBlocks) {
1093
- return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
1094
- };
1095
- var findSubLists = function (parentList) {
1096
- return filter$1(parentList.querySelectorAll('ol,ul,dl'), isListNode);
1097
- };
1098
- var getSelectedSubLists = function (editor) {
1099
- var parentList = getParentList(editor);
1100
- var selectedBlocks = editor.selection.getSelectedBlocks();
766
+ const listNames = [
767
+ 'OL',
768
+ 'UL',
769
+ 'DL'
770
+ ];
771
+ const listSelector = listNames.join(',');
772
+ const getParentList = (editor, node) => {
773
+ const selectionStart = node || editor.selection.getStart(true);
774
+ return editor.dom.getParent(selectionStart, listSelector, getClosestListHost(editor, selectionStart));
775
+ };
776
+ const isParentListSelected = (parentList, selectedBlocks) => isNonNullable(parentList) && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
777
+ const findSubLists = parentList => filter$1(parentList.querySelectorAll(listSelector), isListNode);
778
+ const getSelectedSubLists = editor => {
779
+ const parentList = getParentList(editor);
780
+ const selectedBlocks = editor.selection.getSelectedBlocks();
1101
781
  if (isParentListSelected(parentList, selectedBlocks)) {
1102
782
  return findSubLists(parentList);
1103
783
  } else {
1104
- return filter$1(selectedBlocks, function (elm) {
784
+ return filter$1(selectedBlocks, elm => {
1105
785
  return isListNode(elm) && parentList !== elm;
1106
786
  });
1107
787
  }
1108
788
  };
1109
- var findParentListItemsNodes = function (editor, elms) {
1110
- var listItemsElms = global$2.map(elms, function (elm) {
1111
- var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm));
789
+ const findParentListItemsNodes = (editor, elms) => {
790
+ const listItemsElms = global$2.map(elms, elm => {
791
+ const parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListHost(editor, elm));
1112
792
  return parentLi ? parentLi : elm;
1113
793
  });
1114
- return global$1.unique(listItemsElms);
794
+ return unique(listItemsElms);
1115
795
  };
1116
- var getSelectedListItems = function (editor) {
1117
- var selectedBlocks = editor.selection.getSelectedBlocks();
796
+ const getSelectedListItems = editor => {
797
+ const selectedBlocks = editor.selection.getSelectedBlocks();
1118
798
  return filter$1(findParentListItemsNodes(editor, selectedBlocks), isListItemNode);
1119
799
  };
1120
- var getSelectedDlItems = function (editor) {
1121
- return filter$1(getSelectedListItems(editor), isDlItemNode);
1122
- };
1123
- var getClosestListRootElm = function (editor, elm) {
1124
- var parentTableCell = editor.dom.getParents(elm, 'TD,TH');
800
+ const getSelectedDlItems = editor => filter$1(getSelectedListItems(editor), isDlItemNode);
801
+ const getClosestEditingHost = (editor, elm) => {
802
+ const parentTableCell = editor.dom.getParents(elm, 'TD,TH');
1125
803
  return parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
1126
804
  };
1127
- var findLastParentListNode = function (editor, elm) {
1128
- var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm));
805
+ const isListHost = (schema, node) => !isListNode(node) && !isListItemNode(node) && exists(listNames, listName => schema.isValidChild(node.nodeName, listName));
806
+ const getClosestListHost = (editor, elm) => {
807
+ const parentBlocks = editor.dom.getParents(elm, editor.dom.isBlock);
808
+ const isNotForcedRootBlock = elm => elm.nodeName.toLowerCase() !== getForcedRootBlock(editor);
809
+ const parentBlock = find(parentBlocks, elm => isNotForcedRootBlock(elm) && isListHost(editor.schema, elm));
810
+ return parentBlock.getOr(editor.getBody());
811
+ };
812
+ const isListInsideAnLiWithFirstAndLastNotListElement = list => parent(list).exists(parent => isListItemNode(parent.dom) && firstChild(parent).exists(firstChild => !isListNode(firstChild.dom)) && lastChild(parent).exists(lastChild => !isListNode(lastChild.dom)));
813
+ const findLastParentListNode = (editor, elm) => {
814
+ const parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListHost(editor, elm));
1129
815
  return last(parentLists);
1130
816
  };
1131
- var getSelectedLists = function (editor) {
1132
- var firstList = findLastParentListNode(editor, editor.selection.getStart());
1133
- var subsequentLists = filter$1(editor.selection.getSelectedBlocks(), isOlUlNode);
817
+ const getSelectedLists = editor => {
818
+ const firstList = findLastParentListNode(editor, editor.selection.getStart());
819
+ const subsequentLists = filter$1(editor.selection.getSelectedBlocks(), isOlUlNode);
1134
820
  return firstList.toArray().concat(subsequentLists);
1135
821
  };
1136
- var getSelectedListRoots = function (editor) {
1137
- var selectedLists = getSelectedLists(editor);
1138
- return getUniqueListRoots(editor, selectedLists);
822
+ const getParentLists = editor => {
823
+ const elm = editor.selection.getStart();
824
+ return editor.dom.getParents(elm, 'ol,ul', getClosestListHost(editor, elm));
1139
825
  };
1140
- var getUniqueListRoots = function (editor, lists) {
1141
- var listRoots = map(lists, function (list) {
1142
- return findLastParentListNode(editor, list).getOr(list);
1143
- });
1144
- return global$1.unique(listRoots);
826
+ const getSelectedListRoots = editor => {
827
+ const selectedLists = getSelectedLists(editor);
828
+ const parentLists = getParentLists(editor);
829
+ return find(parentLists, p => isListInsideAnLiWithFirstAndLastNotListElement(SugarElement.fromDom(p))).fold(() => getUniqueListRoots(editor, selectedLists), l => [l]);
830
+ };
831
+ const getUniqueListRoots = (editor, lists) => {
832
+ const listRoots = map(lists, list => findLastParentListNode(editor, list).getOr(list));
833
+ return unique(listRoots);
1145
834
  };
1146
835
 
1147
- var is = function (lhs, rhs, comparator) {
1148
- if (comparator === void 0) {
1149
- comparator = tripleEquals;
1150
- }
1151
- return lhs.exists(function (left) {
1152
- return comparator(left, rhs);
1153
- });
836
+ const isCustomList = list => /\btox\-/.test(list.className);
837
+ const inList = (parents, listName) => findUntil(parents, isListNode, isTableCellNode).exists(list => list.nodeName === listName && !isCustomList(list));
838
+ const isWithinNonEditable = (editor, element) => element !== null && !editor.dom.isEditable(element);
839
+ const selectionIsWithinNonEditableList = editor => {
840
+ const parentList = getParentList(editor);
841
+ return isWithinNonEditable(editor, parentList);
1154
842
  };
1155
- var lift2 = function (oa, ob, f) {
1156
- return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
843
+ const isWithinNonEditableList = (editor, element) => {
844
+ const parentList = editor.dom.getParent(element, 'ol,ul,dl');
845
+ return isWithinNonEditable(editor, parentList);
846
+ };
847
+ const setNodeChangeHandler = (editor, nodeChangeHandler) => {
848
+ const initialNode = editor.selection.getNode();
849
+ nodeChangeHandler({
850
+ parents: editor.dom.getParents(initialNode),
851
+ element: initialNode
852
+ });
853
+ editor.on('NodeChange', nodeChangeHandler);
854
+ return () => editor.off('NodeChange', nodeChangeHandler);
1157
855
  };
1158
856
 
1159
- var fromElements = function (elements, scope) {
1160
- var doc = scope || document;
1161
- var fragment = doc.createDocumentFragment();
1162
- each$1(elements, function (element) {
857
+ const fromElements = (elements, scope) => {
858
+ const doc = scope || document;
859
+ const fragment = doc.createDocumentFragment();
860
+ each$1(elements, element => {
1163
861
  fragment.appendChild(element.dom);
1164
862
  });
1165
863
  return SugarElement.fromDom(fragment);
1166
864
  };
1167
865
 
1168
- var fireListEvent = function (editor, action, element) {
1169
- return editor.fire('ListMutation', {
1170
- action: action,
1171
- element: element
1172
- });
1173
- };
866
+ const fireListEvent = (editor, action, element) => editor.dispatch('ListMutation', {
867
+ action,
868
+ element
869
+ });
1174
870
 
1175
- var isSupported = function (dom) {
1176
- return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
1177
- };
871
+ const blank = r => s => s.replace(r, '');
872
+ const trim = blank(/^\s+|\s+$/g);
873
+ const isNotEmpty = s => s.length > 0;
874
+ const isEmpty$1 = s => !isNotEmpty(s);
1178
875
 
1179
- var internalSet = function (dom, property, value) {
876
+ const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
877
+
878
+ const internalSet = (dom, property, value) => {
1180
879
  if (!isString(value)) {
1181
880
  console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
1182
881
  throw new Error('CSS value must be a string: ' + value);
@@ -1185,124 +884,137 @@
1185
884
  dom.style.setProperty(property, value);
1186
885
  }
1187
886
  };
1188
- var set = function (element, property, value) {
1189
- var dom = element.dom;
887
+ const set = (element, property, value) => {
888
+ const dom = element.dom;
1190
889
  internalSet(dom, property, value);
1191
890
  };
1192
891
 
1193
- var joinSegment = function (parent, child) {
892
+ const isList = el => is(el, 'OL,UL');
893
+ const isListItem = el => is(el, 'LI');
894
+ const hasFirstChildList = el => firstChild(el).exists(isList);
895
+ const hasLastChildList = el => lastChild(el).exists(isList);
896
+
897
+ const isEntryList = entry => 'listAttributes' in entry;
898
+ const isEntryComment = entry => 'isComment' in entry;
899
+ const isEntryFragment = entry => 'isFragment' in entry;
900
+ const isIndented = entry => entry.depth > 0;
901
+ const isSelected = entry => entry.isSelected;
902
+ const cloneItemContent = li => {
903
+ const children$1 = children(li);
904
+ const content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
905
+ return map(content, deep);
906
+ };
907
+ const createEntry = (li, depth, isSelected) => parent(li).filter(isElement$1).map(list => ({
908
+ depth,
909
+ dirty: false,
910
+ isSelected,
911
+ content: cloneItemContent(li),
912
+ itemAttributes: clone$1(li),
913
+ listAttributes: clone$1(list),
914
+ listType: name(list),
915
+ isInPreviousLi: false
916
+ }));
917
+
918
+ const joinSegment = (parent, child) => {
1194
919
  append$1(parent.item, child.list);
1195
920
  };
1196
- var joinSegments = function (segments) {
1197
- for (var i = 1; i < segments.length; i++) {
921
+ const joinSegments = segments => {
922
+ for (let i = 1; i < segments.length; i++) {
1198
923
  joinSegment(segments[i - 1], segments[i]);
1199
924
  }
1200
925
  };
1201
- var appendSegments = function (head$1, tail) {
926
+ const appendSegments = (head$1, tail) => {
1202
927
  lift2(last(head$1), head(tail), joinSegment);
1203
928
  };
1204
- var createSegment = function (scope, listType) {
1205
- var segment = {
929
+ const createSegment = (scope, listType) => {
930
+ const segment = {
1206
931
  list: SugarElement.fromTag(listType, scope),
1207
932
  item: SugarElement.fromTag('li', scope)
1208
933
  };
1209
934
  append$1(segment.list, segment.item);
1210
935
  return segment;
1211
936
  };
1212
- var createSegments = function (scope, entry, size) {
1213
- var segments = [];
1214
- for (var i = 0; i < size; i++) {
1215
- segments.push(createSegment(scope, entry.listType));
937
+ const createSegments = (scope, entry, size) => {
938
+ const segments = [];
939
+ for (let i = 0; i < size; i++) {
940
+ segments.push(createSegment(scope, isEntryList(entry) ? entry.listType : entry.parentListType));
1216
941
  }
1217
942
  return segments;
1218
943
  };
1219
- var populateSegments = function (segments, entry) {
1220
- for (var i = 0; i < segments.length - 1; i++) {
944
+ const populateSegments = (segments, entry) => {
945
+ for (let i = 0; i < segments.length - 1; i++) {
1221
946
  set(segments[i].item, 'list-style-type', 'none');
1222
947
  }
1223
- last(segments).each(function (segment) {
1224
- setAll(segment.list, entry.listAttributes);
1225
- setAll(segment.item, entry.itemAttributes);
948
+ last(segments).each(segment => {
949
+ if (isEntryList(entry)) {
950
+ setAll(segment.list, entry.listAttributes);
951
+ setAll(segment.item, entry.itemAttributes);
952
+ }
1226
953
  append(segment.item, entry.content);
1227
954
  });
1228
955
  };
1229
- var normalizeSegment = function (segment, entry) {
956
+ const normalizeSegment = (segment, entry) => {
1230
957
  if (name(segment.list) !== entry.listType) {
1231
958
  segment.list = mutate(segment.list, entry.listType);
1232
959
  }
1233
960
  setAll(segment.list, entry.listAttributes);
1234
961
  };
1235
- var createItem = function (scope, attr, content) {
1236
- var item = SugarElement.fromTag('li', scope);
962
+ const createItem = (scope, attr, content) => {
963
+ const item = SugarElement.fromTag('li', scope);
1237
964
  setAll(item, attr);
1238
965
  append(item, content);
1239
966
  return item;
1240
967
  };
1241
- var appendItem = function (segment, item) {
968
+ const appendItem = (segment, item) => {
1242
969
  append$1(segment.list, item);
1243
970
  segment.item = item;
1244
971
  };
1245
- var writeShallow = function (scope, cast, entry) {
1246
- var newCast = cast.slice(0, entry.depth);
1247
- last(newCast).each(function (segment) {
1248
- var item = createItem(scope, entry.itemAttributes, entry.content);
1249
- appendItem(segment, item);
1250
- normalizeSegment(segment, entry);
972
+ const writeShallow = (scope, cast, entry) => {
973
+ const newCast = cast.slice(0, entry.depth);
974
+ last(newCast).each(segment => {
975
+ if (isEntryList(entry)) {
976
+ const item = createItem(scope, entry.itemAttributes, entry.content);
977
+ appendItem(segment, item);
978
+ normalizeSegment(segment, entry);
979
+ } else if (isEntryFragment(entry)) {
980
+ append(segment.item, entry.content);
981
+ } else {
982
+ const item = SugarElement.fromHtml(`<!--${ entry.content }-->`);
983
+ append$1(segment.list, item);
984
+ }
1251
985
  });
1252
986
  return newCast;
1253
987
  };
1254
- var writeDeep = function (scope, cast, entry) {
1255
- var segments = createSegments(scope, entry, entry.depth - cast.length);
988
+ const writeDeep = (scope, cast, entry) => {
989
+ const segments = createSegments(scope, entry, entry.depth - cast.length);
1256
990
  joinSegments(segments);
1257
991
  populateSegments(segments, entry);
1258
992
  appendSegments(cast, segments);
1259
993
  return cast.concat(segments);
1260
994
  };
1261
- var composeList = function (scope, entries) {
1262
- var cast = foldl(entries, function (cast, entry) {
1263
- return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
995
+ const composeList = (scope, entries) => {
996
+ let firstCommentEntryOpt = Optional.none();
997
+ const cast = foldl(entries, (cast, entry, i) => {
998
+ if (!isEntryComment(entry)) {
999
+ return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
1000
+ } else {
1001
+ if (i === 0) {
1002
+ firstCommentEntryOpt = Optional.some(entry);
1003
+ return cast;
1004
+ }
1005
+ return writeShallow(scope, cast, entry);
1006
+ }
1264
1007
  }, []);
1265
- return head(cast).map(function (segment) {
1266
- return segment.list;
1267
- });
1268
- };
1269
-
1270
- var isList = function (el) {
1271
- return is$1(el, 'OL,UL');
1272
- };
1273
- var hasFirstChildList = function (el) {
1274
- return firstChild(el).exists(isList);
1275
- };
1276
- var hasLastChildList = function (el) {
1277
- return lastChild(el).exists(isList);
1278
- };
1279
-
1280
- var isIndented = function (entry) {
1281
- return entry.depth > 0;
1282
- };
1283
- var isSelected = function (entry) {
1284
- return entry.isSelected;
1285
- };
1286
- var cloneItemContent = function (li) {
1287
- var children$1 = children(li);
1288
- var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
1289
- return map(content, deep);
1290
- };
1291
- var createEntry = function (li, depth, isSelected) {
1292
- return parent(li).filter(isElement).map(function (list) {
1293
- return {
1294
- depth: depth,
1295
- dirty: false,
1296
- isSelected: isSelected,
1297
- content: cloneItemContent(li),
1298
- itemAttributes: clone$1(li),
1299
- listAttributes: clone$1(list),
1300
- listType: name(list)
1301
- };
1008
+ firstCommentEntryOpt.each(firstCommentEntry => {
1009
+ const item = SugarElement.fromHtml(`<!--${ firstCommentEntry.content }-->`);
1010
+ head(cast).each(fistCast => {
1011
+ prepend(fistCast.list, item);
1012
+ });
1302
1013
  });
1014
+ return head(cast).map(segment => segment.list);
1303
1015
  };
1304
1016
 
1305
- var indentEntry = function (indentation, entry) {
1017
+ const indentEntry = (indentation, entry) => {
1306
1018
  switch (indentation) {
1307
1019
  case 'Indent':
1308
1020
  entry.depth++;
@@ -1316,130 +1028,138 @@
1316
1028
  entry.dirty = true;
1317
1029
  };
1318
1030
 
1319
- var cloneListProperties = function (target, source) {
1320
- target.listType = source.listType;
1321
- target.listAttributes = __assign({}, source.listAttributes);
1031
+ const cloneListProperties = (target, source) => {
1032
+ if (isEntryList(target) && isEntryList(source)) {
1033
+ target.listType = source.listType;
1034
+ target.listAttributes = { ...source.listAttributes };
1035
+ }
1322
1036
  };
1323
- var cleanListProperties = function (entry) {
1324
- entry.listAttributes = filter(entry.listAttributes, function (_value, key) {
1325
- return key !== 'start';
1326
- });
1037
+ const cleanListProperties = entry => {
1038
+ entry.listAttributes = filter(entry.listAttributes, (_value, key) => key !== 'start');
1327
1039
  };
1328
- var closestSiblingEntry = function (entries, start) {
1329
- var depth = entries[start].depth;
1330
- var matches = function (entry) {
1331
- return entry.depth === depth && !entry.dirty;
1332
- };
1333
- var until = function (entry) {
1334
- return entry.depth < depth;
1335
- };
1336
- return findUntil(reverse(entries.slice(0, start)), matches, until).orThunk(function () {
1337
- return findUntil(entries.slice(start + 1), matches, until);
1338
- });
1040
+ const closestSiblingEntry = (entries, start) => {
1041
+ const depth = entries[start].depth;
1042
+ const matches = entry => entry.depth === depth && !entry.dirty;
1043
+ const until = entry => entry.depth < depth;
1044
+ return findUntil(reverse(entries.slice(0, start)), matches, until).orThunk(() => findUntil(entries.slice(start + 1), matches, until));
1339
1045
  };
1340
- var normalizeEntries = function (entries) {
1341
- each$1(entries, function (entry, i) {
1342
- closestSiblingEntry(entries, i).fold(function () {
1343
- if (entry.dirty) {
1046
+ const normalizeEntries = entries => {
1047
+ each$1(entries, (entry, i) => {
1048
+ closestSiblingEntry(entries, i).fold(() => {
1049
+ if (entry.dirty && isEntryList(entry)) {
1344
1050
  cleanListProperties(entry);
1345
1051
  }
1346
- }, function (matchingEntry) {
1347
- return cloneListProperties(entry, matchingEntry);
1348
- });
1052
+ }, matchingEntry => cloneListProperties(entry, matchingEntry));
1349
1053
  });
1350
1054
  return entries;
1351
1055
  };
1352
1056
 
1353
- var Cell = function (initial) {
1354
- var value = initial;
1355
- var get = function () {
1057
+ const Cell = initial => {
1058
+ let value = initial;
1059
+ const get = () => {
1356
1060
  return value;
1357
1061
  };
1358
- var set = function (v) {
1062
+ const set = v => {
1359
1063
  value = v;
1360
1064
  };
1361
1065
  return {
1362
- get: get,
1363
- set: set
1066
+ get,
1067
+ set
1364
1068
  };
1365
1069
  };
1366
1070
 
1367
- var parseItem = function (depth, itemSelection, selectionState, item) {
1368
- return firstChild(item).filter(isList).fold(function () {
1369
- itemSelection.each(function (selection) {
1370
- if (eq(selection.start, item)) {
1371
- selectionState.set(true);
1372
- }
1373
- });
1374
- var currentItemEntry = createEntry(item, depth, selectionState.get());
1375
- itemSelection.each(function (selection) {
1376
- if (eq(selection.end, item)) {
1377
- selectionState.set(false);
1378
- }
1379
- });
1380
- var childListEntries = lastChild(item).filter(isList).map(function (list) {
1381
- return parseList(depth, itemSelection, selectionState, list);
1382
- }).getOr([]);
1383
- return currentItemEntry.toArray().concat(childListEntries);
1384
- }, function (list) {
1385
- return parseList(depth, itemSelection, selectionState, list);
1386
- });
1387
- };
1388
- var parseList = function (depth, itemSelection, selectionState, list) {
1389
- return bind(children(list), function (element) {
1390
- var parser = isList(element) ? parseList : parseItem;
1391
- var newDepth = depth + 1;
1392
- return parser(newDepth, itemSelection, selectionState, element);
1071
+ const parseSingleItem = (depth, itemSelection, selectionState, item) => {
1072
+ var _a;
1073
+ if (isComment(item)) {
1074
+ return [{
1075
+ depth: depth + 1,
1076
+ content: (_a = item.dom.nodeValue) !== null && _a !== void 0 ? _a : '',
1077
+ dirty: false,
1078
+ isSelected: false,
1079
+ isComment: true
1080
+ }];
1081
+ }
1082
+ itemSelection.each(selection => {
1083
+ if (eq(selection.start, item)) {
1084
+ selectionState.set(true);
1085
+ }
1393
1086
  });
1394
- };
1395
- var parseLists = function (lists, itemSelection) {
1396
- var selectionState = Cell(false);
1397
- var initialDepth = 0;
1398
- return map(lists, function (list) {
1399
- return {
1400
- sourceList: list,
1401
- entries: parseList(initialDepth, itemSelection, selectionState, list)
1402
- };
1087
+ const currentItemEntry = createEntry(item, depth, selectionState.get());
1088
+ itemSelection.each(selection => {
1089
+ if (eq(selection.end, item)) {
1090
+ selectionState.set(false);
1091
+ }
1403
1092
  });
1093
+ const childListEntries = lastChild(item).filter(isList).map(list => parseList(depth, itemSelection, selectionState, list)).getOr([]);
1094
+ return currentItemEntry.toArray().concat(childListEntries);
1404
1095
  };
1405
-
1406
- var outdentedComposer = function (editor, entries) {
1407
- var normalizedEntries = normalizeEntries(entries);
1408
- return map(normalizedEntries, function (entry) {
1409
- var content = fromElements(entry.content);
1096
+ const parseItem = (depth, itemSelection, selectionState, item) => firstChild(item).filter(isList).fold(() => parseSingleItem(depth, itemSelection, selectionState, item), list => {
1097
+ const parsedSiblings = foldl(children(item), (acc, liChild, i) => {
1098
+ if (i === 0) {
1099
+ return acc;
1100
+ } else {
1101
+ if (isListItem(liChild)) {
1102
+ return acc.concat(parseSingleItem(depth, itemSelection, selectionState, liChild));
1103
+ } else {
1104
+ const fragment = {
1105
+ isFragment: true,
1106
+ depth,
1107
+ content: [liChild],
1108
+ isSelected: false,
1109
+ dirty: false,
1110
+ parentListType: name(list)
1111
+ };
1112
+ return acc.concat(fragment);
1113
+ }
1114
+ }
1115
+ }, []);
1116
+ return parseList(depth, itemSelection, selectionState, list).concat(parsedSiblings);
1117
+ });
1118
+ const parseList = (depth, itemSelection, selectionState, list) => bind(children(list), element => {
1119
+ const parser = isList(element) ? parseList : parseItem;
1120
+ const newDepth = depth + 1;
1121
+ return parser(newDepth, itemSelection, selectionState, element);
1122
+ });
1123
+ const parseLists = (lists, itemSelection) => {
1124
+ const selectionState = Cell(false);
1125
+ const initialDepth = 0;
1126
+ return map(lists, list => ({
1127
+ sourceList: list,
1128
+ entries: parseList(initialDepth, itemSelection, selectionState, list)
1129
+ }));
1130
+ };
1131
+
1132
+ const outdentedComposer = (editor, entries) => {
1133
+ const normalizedEntries = normalizeEntries(entries);
1134
+ return map(normalizedEntries, entry => {
1135
+ const content = !isEntryComment(entry) ? fromElements(entry.content) : fromElements([SugarElement.fromHtml(`<!--${ entry.content }-->`)]);
1410
1136
  return SugarElement.fromDom(createTextBlock(editor, content.dom));
1411
1137
  });
1412
1138
  };
1413
- var indentedComposer = function (editor, entries) {
1414
- var normalizedEntries = normalizeEntries(entries);
1139
+ const indentedComposer = (editor, entries) => {
1140
+ const normalizedEntries = normalizeEntries(entries);
1415
1141
  return composeList(editor.contentDocument, normalizedEntries).toArray();
1416
1142
  };
1417
- var composeEntries = function (editor, entries) {
1418
- return bind(groupBy(entries, isIndented), function (entries) {
1419
- var groupIsIndented = head(entries).exists(isIndented);
1420
- return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
1421
- });
1422
- };
1423
- var indentSelectedEntries = function (entries, indentation) {
1424
- each$1(filter$1(entries, isSelected), function (entry) {
1425
- return indentEntry(indentation, entry);
1426
- });
1427
- };
1428
- var getItemSelection = function (editor) {
1429
- var selectedListItems = map(getSelectedListItems(editor), SugarElement.fromDom);
1430
- return lift2(find$1(selectedListItems, not(hasFirstChildList)), find$1(reverse(selectedListItems), not(hasFirstChildList)), function (start, end) {
1431
- return {
1432
- start: start,
1433
- end: end
1434
- };
1435
- });
1436
- };
1437
- var listIndentation = function (editor, lists, indentation) {
1438
- var entrySets = parseLists(lists, getItemSelection(editor));
1439
- each$1(entrySets, function (entrySet) {
1143
+ const composeEntries = (editor, entries) => bind(groupBy(entries, isIndented), entries => {
1144
+ const groupIsIndented = head(entries).exists(isIndented);
1145
+ return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
1146
+ });
1147
+ const indentSelectedEntries = (entries, indentation) => {
1148
+ each$1(filter$1(entries, isSelected), entry => indentEntry(indentation, entry));
1149
+ };
1150
+ const getItemSelection = editor => {
1151
+ const selectedListItems = map(getSelectedListItems(editor), SugarElement.fromDom);
1152
+ return lift2(find(selectedListItems, not(hasFirstChildList)), find(reverse(selectedListItems), not(hasFirstChildList)), (start, end) => ({
1153
+ start,
1154
+ end
1155
+ }));
1156
+ };
1157
+ const listIndentation = (editor, lists, indentation) => {
1158
+ const entrySets = parseLists(lists, getItemSelection(editor));
1159
+ each$1(entrySets, entrySet => {
1440
1160
  indentSelectedEntries(entrySet.entries, indentation);
1441
- var composedLists = composeEntries(editor, entrySet.entries);
1442
- each$1(composedLists, function (composedList) {
1161
+ const composedLists = composeEntries(editor, entrySet.entries);
1162
+ each$1(composedLists, composedList => {
1443
1163
  fireListEvent(editor, indentation === 'Indent' ? 'IndentList' : 'OutdentList', composedList.dom);
1444
1164
  });
1445
1165
  before(entrySet.sourceList, composedLists);
@@ -1447,12 +1167,12 @@
1447
1167
  });
1448
1168
  };
1449
1169
 
1450
- var selectionIndentation = function (editor, indentation) {
1451
- var lists = map(getSelectedListRoots(editor), SugarElement.fromDom);
1452
- var dlItems = map(getSelectedDlItems(editor), SugarElement.fromDom);
1453
- var isHandled = false;
1170
+ const selectionIndentation = (editor, indentation) => {
1171
+ const lists = fromDom(getSelectedListRoots(editor));
1172
+ const dlItems = fromDom(getSelectedDlItems(editor));
1173
+ let isHandled = false;
1454
1174
  if (lists.length || dlItems.length) {
1455
- var bookmark = editor.selection.getBookmark();
1175
+ const bookmark = editor.selection.getBookmark();
1456
1176
  listIndentation(editor, lists, indentation);
1457
1177
  dlIndentation(editor, indentation, dlItems);
1458
1178
  editor.selection.moveToBookmark(bookmark);
@@ -1462,26 +1182,28 @@
1462
1182
  }
1463
1183
  return isHandled;
1464
1184
  };
1465
- var indentListSelection = function (editor) {
1466
- return selectionIndentation(editor, 'Indent');
1467
- };
1468
- var outdentListSelection = function (editor) {
1469
- return selectionIndentation(editor, 'Outdent');
1470
- };
1471
- var flattenListSelection = function (editor) {
1472
- return selectionIndentation(editor, 'Flatten');
1473
- };
1185
+ const handleIndentation = (editor, indentation) => !selectionIsWithinNonEditableList(editor) && selectionIndentation(editor, indentation);
1186
+ const indentListSelection = editor => handleIndentation(editor, 'Indent');
1187
+ const outdentListSelection = editor => handleIndentation(editor, 'Outdent');
1188
+ const flattenListSelection = editor => handleIndentation(editor, 'Flatten');
1189
+
1190
+ const zeroWidth = '\uFEFF';
1191
+ const isZwsp = char => char === zeroWidth;
1192
+
1193
+ const ancestor$1 = (scope, predicate, isRoot) => ancestor$3(scope, predicate, isRoot).isSome();
1194
+
1195
+ const ancestor = (element, target) => ancestor$1(element, curry(eq, target));
1474
1196
 
1475
- var global = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager');
1197
+ var global$1 = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager');
1476
1198
 
1477
- var DOM$1 = global$3.DOM;
1478
- var createBookmark = function (rng) {
1479
- var bookmark = {};
1480
- var setupEndPoint = function (start) {
1481
- var container = rng[start ? 'startContainer' : 'endContainer'];
1482
- var offset = rng[start ? 'startOffset' : 'endOffset'];
1483
- if (container.nodeType === 1) {
1484
- var offsetNode = DOM$1.create('span', { 'data-mce-type': 'bookmark' });
1199
+ const DOM$1 = global$3.DOM;
1200
+ const createBookmark = rng => {
1201
+ const bookmark = {};
1202
+ const setupEndPoint = start => {
1203
+ let container = rng[start ? 'startContainer' : 'endContainer'];
1204
+ let offset = rng[start ? 'startOffset' : 'endOffset'];
1205
+ if (isElement(container)) {
1206
+ const offsetNode = DOM$1.create('span', { 'data-mce-type': 'bookmark' });
1485
1207
  if (container.hasChildNodes()) {
1486
1208
  offset = Math.min(offset, container.childNodes.length - 1);
1487
1209
  if (start) {
@@ -1504,28 +1226,30 @@
1504
1226
  }
1505
1227
  return bookmark;
1506
1228
  };
1507
- var resolveBookmark = function (bookmark) {
1508
- var restoreEndPoint = function (start) {
1509
- var node;
1510
- var nodeIndex = function (container) {
1511
- var node = container.parentNode.firstChild, idx = 0;
1229
+ const resolveBookmark = bookmark => {
1230
+ const restoreEndPoint = start => {
1231
+ const nodeIndex = container => {
1232
+ var _a;
1233
+ let node = (_a = container.parentNode) === null || _a === void 0 ? void 0 : _a.firstChild;
1234
+ let idx = 0;
1512
1235
  while (node) {
1513
1236
  if (node === container) {
1514
1237
  return idx;
1515
1238
  }
1516
- if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
1239
+ if (!isElement(node) || node.getAttribute('data-mce-type') !== 'bookmark') {
1517
1240
  idx++;
1518
1241
  }
1519
1242
  node = node.nextSibling;
1520
1243
  }
1521
1244
  return -1;
1522
1245
  };
1523
- var container = node = bookmark[start ? 'startContainer' : 'endContainer'];
1524
- var offset = bookmark[start ? 'startOffset' : 'endOffset'];
1246
+ let container = bookmark[start ? 'startContainer' : 'endContainer'];
1247
+ let offset = bookmark[start ? 'startOffset' : 'endOffset'];
1525
1248
  if (!container) {
1526
1249
  return;
1527
1250
  }
1528
- if (container.nodeType === 1) {
1251
+ if (isElement(container) && container.parentNode) {
1252
+ const node = container;
1529
1253
  offset = nodeIndex(container);
1530
1254
  container = container.parentNode;
1531
1255
  DOM$1.remove(node);
@@ -1538,7 +1262,7 @@
1538
1262
  };
1539
1263
  restoreEndPoint(true);
1540
1264
  restoreEndPoint();
1541
- var rng = DOM$1.createRng();
1265
+ const rng = DOM$1.createRng();
1542
1266
  rng.setStart(bookmark.startContainer, bookmark.startOffset);
1543
1267
  if (bookmark.endContainer) {
1544
1268
  rng.setEnd(bookmark.endContainer, bookmark.endOffset);
@@ -1546,7 +1270,7 @@
1546
1270
  return normalizeRange(rng);
1547
1271
  };
1548
1272
 
1549
- var listToggleActionFromListName = function (listName) {
1273
+ const listToggleActionFromListName = listName => {
1550
1274
  switch (listName) {
1551
1275
  case 'UL':
1552
1276
  return 'ToggleUlList';
@@ -1557,83 +1281,107 @@
1557
1281
  }
1558
1282
  };
1559
1283
 
1560
- var isCustomList = function (list) {
1561
- return /\btox\-/.test(list.className);
1562
- };
1563
- var listState = function (editor, listName, activate) {
1564
- var nodeChangeHandler = function (e) {
1565
- var inList = findUntil(e.parents, isListNode, isTableCellNode).filter(function (list) {
1566
- return list.nodeName === listName && !isCustomList(list);
1567
- }).isSome();
1568
- activate(inList);
1569
- };
1570
- var parents = editor.dom.getParents(editor.selection.getNode());
1571
- nodeChangeHandler({ parents: parents });
1572
- editor.on('NodeChange', nodeChangeHandler);
1573
- return function () {
1574
- return editor.off('NodeChange', nodeChangeHandler);
1575
- };
1576
- };
1577
-
1578
- var updateListStyle = function (dom, el, detail) {
1579
- var type = detail['list-style-type'] ? detail['list-style-type'] : null;
1284
+ const updateListStyle = (dom, el, detail) => {
1285
+ const type = detail['list-style-type'] ? detail['list-style-type'] : null;
1580
1286
  dom.setStyle(el, 'list-style-type', type);
1581
1287
  };
1582
- var setAttribs = function (elm, attrs) {
1583
- global$2.each(attrs, function (value, key) {
1288
+ const setAttribs = (elm, attrs) => {
1289
+ global$2.each(attrs, (value, key) => {
1584
1290
  elm.setAttribute(key, value);
1585
1291
  });
1586
1292
  };
1587
- var updateListAttrs = function (dom, el, detail) {
1293
+ const updateListAttrs = (dom, el, detail) => {
1588
1294
  setAttribs(el, detail['list-attributes']);
1589
- global$2.each(dom.select('li', el), function (li) {
1295
+ global$2.each(dom.select('li', el), li => {
1590
1296
  setAttribs(li, detail['list-item-attributes']);
1591
1297
  });
1592
1298
  };
1593
- var updateListWithDetails = function (dom, el, detail) {
1299
+ const updateListWithDetails = (dom, el, detail) => {
1594
1300
  updateListStyle(dom, el, detail);
1595
1301
  updateListAttrs(dom, el, detail);
1596
1302
  };
1597
- var removeStyles = function (dom, element, styles) {
1598
- global$2.each(styles, function (style) {
1599
- var _a;
1600
- return dom.setStyle(element, (_a = {}, _a[style] = '', _a));
1601
- });
1303
+ const removeStyles = (dom, element, styles) => {
1304
+ global$2.each(styles, style => dom.setStyle(element, style, ''));
1602
1305
  };
1603
- var getEndPointNode = function (editor, rng, start, root) {
1604
- var container = rng[start ? 'startContainer' : 'endContainer'];
1605
- var offset = rng[start ? 'startOffset' : 'endOffset'];
1606
- if (container.nodeType === 1) {
1306
+ const isInline = (editor, node) => isNonNullable(node) && !isBlock(node, editor.schema.getBlockElements());
1307
+ const getEndPointNode = (editor, rng, start, root) => {
1308
+ let container = rng[start ? 'startContainer' : 'endContainer'];
1309
+ const offset = rng[start ? 'startOffset' : 'endOffset'];
1310
+ if (isElement(container)) {
1607
1311
  container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
1608
1312
  }
1609
1313
  if (!start && isBr(container.nextSibling)) {
1610
1314
  container = container.nextSibling;
1611
1315
  }
1316
+ const findBlockAncestor = node => {
1317
+ while (!editor.dom.isBlock(node) && node.parentNode && root !== node) {
1318
+ node = node.parentNode;
1319
+ }
1320
+ return node;
1321
+ };
1322
+ const findBetterContainer = (container, forward) => {
1323
+ var _a;
1324
+ const walker = new global$5(container, findBlockAncestor(container));
1325
+ const dir = forward ? 'next' : 'prev';
1326
+ let node;
1327
+ while (node = walker[dir]()) {
1328
+ if (!(isVoid(editor, node) || isZwsp(node.textContent) || ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.length) === 0)) {
1329
+ return Optional.some(node);
1330
+ }
1331
+ }
1332
+ return Optional.none();
1333
+ };
1334
+ if (start && isTextNode$1(container)) {
1335
+ if (isZwsp(container.textContent)) {
1336
+ container = findBetterContainer(container, false).getOr(container);
1337
+ } else {
1338
+ if (container.parentNode !== null && isInline(editor, container.parentNode)) {
1339
+ container = container.parentNode;
1340
+ }
1341
+ while (container.previousSibling !== null && (isInline(editor, container.previousSibling) || isTextNode$1(container.previousSibling))) {
1342
+ container = container.previousSibling;
1343
+ }
1344
+ }
1345
+ }
1346
+ if (!start && isTextNode$1(container)) {
1347
+ if (isZwsp(container.textContent)) {
1348
+ container = findBetterContainer(container, true).getOr(container);
1349
+ } else {
1350
+ if (container.parentNode !== null && isInline(editor, container.parentNode)) {
1351
+ container = container.parentNode;
1352
+ }
1353
+ while (container.nextSibling !== null && (isInline(editor, container.nextSibling) || isTextNode$1(container.nextSibling))) {
1354
+ container = container.nextSibling;
1355
+ }
1356
+ }
1357
+ }
1612
1358
  while (container.parentNode !== root) {
1359
+ const parent = container.parentNode;
1613
1360
  if (isTextBlock(editor, container)) {
1614
1361
  return container;
1615
1362
  }
1616
- if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
1363
+ if (/^(TD|TH)$/.test(parent.nodeName)) {
1617
1364
  return container;
1618
1365
  }
1619
- container = container.parentNode;
1366
+ container = parent;
1620
1367
  }
1621
1368
  return container;
1622
1369
  };
1623
- var getSelectedTextBlocks = function (editor, rng, root) {
1624
- var textBlocks = [];
1625
- var dom = editor.dom;
1626
- var startNode = getEndPointNode(editor, rng, true, root);
1627
- var endNode = getEndPointNode(editor, rng, false, root);
1628
- var block;
1629
- var siblings = [];
1630
- for (var node = startNode; node; node = node.nextSibling) {
1370
+ const getSelectedTextBlocks = (editor, rng, root) => {
1371
+ const textBlocks = [];
1372
+ const dom = editor.dom;
1373
+ const startNode = getEndPointNode(editor, rng, true, root);
1374
+ const endNode = getEndPointNode(editor, rng, false, root);
1375
+ let block;
1376
+ const siblings = [];
1377
+ for (let node = startNode; node; node = node.nextSibling) {
1631
1378
  siblings.push(node);
1632
1379
  if (node === endNode) {
1633
1380
  break;
1634
1381
  }
1635
1382
  }
1636
- global$2.each(siblings, function (node) {
1383
+ global$2.each(siblings, node => {
1384
+ var _a;
1637
1385
  if (isTextBlock(editor, node)) {
1638
1386
  textBlocks.push(node);
1639
1387
  block = null;
@@ -1646,8 +1394,8 @@
1646
1394
  block = null;
1647
1395
  return;
1648
1396
  }
1649
- var nextSibling = node.nextSibling;
1650
- if (global.isBookmarkNode(node)) {
1397
+ const nextSibling = node.nextSibling;
1398
+ if (global$1.isBookmarkNode(node)) {
1651
1399
  if (isListNode(nextSibling) || isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) {
1652
1400
  block = null;
1653
1401
  return;
@@ -1655,24 +1403,33 @@
1655
1403
  }
1656
1404
  if (!block) {
1657
1405
  block = dom.create('p');
1658
- node.parentNode.insertBefore(block, node);
1406
+ (_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(block, node);
1659
1407
  textBlocks.push(block);
1660
1408
  }
1661
1409
  block.appendChild(node);
1662
1410
  });
1663
1411
  return textBlocks;
1664
1412
  };
1665
- var hasCompatibleStyle = function (dom, sib, detail) {
1666
- var sibStyle = dom.getStyle(sib, 'list-style-type');
1667
- var detailStyle = detail ? detail['list-style-type'] : '';
1413
+ const hasCompatibleStyle = (dom, sib, detail) => {
1414
+ const sibStyle = dom.getStyle(sib, 'list-style-type');
1415
+ let detailStyle = detail ? detail['list-style-type'] : '';
1668
1416
  detailStyle = detailStyle === null ? '' : detailStyle;
1669
1417
  return sibStyle === detailStyle;
1670
1418
  };
1671
- var applyList = function (editor, listName, detail) {
1672
- var rng = editor.selection.getRng();
1673
- var listItemName = 'LI';
1674
- var root = getClosestListRootElm(editor, editor.selection.getStart(true));
1675
- var dom = editor.dom;
1419
+ const getRootSearchStart = (editor, range) => {
1420
+ const start = editor.selection.getStart(true);
1421
+ const startPoint = getEndPointNode(editor, range, true, editor.getBody());
1422
+ if (ancestor(SugarElement.fromDom(startPoint), SugarElement.fromDom(range.commonAncestorContainer))) {
1423
+ return range.commonAncestorContainer;
1424
+ } else {
1425
+ return start;
1426
+ }
1427
+ };
1428
+ const applyList = (editor, listName, detail) => {
1429
+ const rng = editor.selection.getRng();
1430
+ let listItemName = 'LI';
1431
+ const root = getClosestListHost(editor, getRootSearchStart(editor, rng));
1432
+ const dom = editor.dom;
1676
1433
  if (dom.getContentEditable(editor.selection.getNode()) === 'false') {
1677
1434
  return;
1678
1435
  }
@@ -1680,12 +1437,12 @@
1680
1437
  if (listName === 'DL') {
1681
1438
  listItemName = 'DT';
1682
1439
  }
1683
- var bookmark = createBookmark(rng);
1684
- var selectedTextBlocks = getSelectedTextBlocks(editor, rng, root);
1685
- global$2.each(selectedTextBlocks, function (block) {
1686
- var listBlock;
1687
- var sibling = block.previousSibling;
1688
- var parent = block.parentNode;
1440
+ const bookmark = createBookmark(rng);
1441
+ const selectedTextBlocks = filter$1(getSelectedTextBlocks(editor, rng, root), editor.dom.isEditable);
1442
+ global$2.each(selectedTextBlocks, block => {
1443
+ let listBlock;
1444
+ const sibling = block.previousSibling;
1445
+ const parent = block.parentNode;
1689
1446
  if (!isListItemNode(parent)) {
1690
1447
  if (sibling && isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
1691
1448
  listBlock = sibling;
@@ -1693,7 +1450,7 @@
1693
1450
  sibling.appendChild(block);
1694
1451
  } else {
1695
1452
  listBlock = dom.create(listName);
1696
- block.parentNode.insertBefore(listBlock, block);
1453
+ parent.insertBefore(listBlock, block);
1697
1454
  listBlock.appendChild(block);
1698
1455
  block = dom.rename(block, listItemName);
1699
1456
  }
@@ -1715,40 +1472,42 @@
1715
1472
  });
1716
1473
  editor.selection.setRng(resolveBookmark(bookmark));
1717
1474
  };
1718
- var isValidLists = function (list1, list2) {
1719
- return list1 && list2 && isListNode(list1) && list1.nodeName === list2.nodeName;
1475
+ const isValidLists = (list1, list2) => {
1476
+ return isListNode(list1) && list1.nodeName === (list2 === null || list2 === void 0 ? void 0 : list2.nodeName);
1720
1477
  };
1721
- var hasSameListStyle = function (dom, list1, list2) {
1722
- var targetStyle = dom.getStyle(list1, 'list-style-type', true);
1723
- var style = dom.getStyle(list2, 'list-style-type', true);
1478
+ const hasSameListStyle = (dom, list1, list2) => {
1479
+ const targetStyle = dom.getStyle(list1, 'list-style-type', true);
1480
+ const style = dom.getStyle(list2, 'list-style-type', true);
1724
1481
  return targetStyle === style;
1725
1482
  };
1726
- var hasSameClasses = function (elm1, elm2) {
1483
+ const hasSameClasses = (elm1, elm2) => {
1727
1484
  return elm1.className === elm2.className;
1728
1485
  };
1729
- var shouldMerge = function (dom, list1, list2) {
1486
+ const shouldMerge = (dom, list1, list2) => {
1730
1487
  return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
1731
1488
  };
1732
- var mergeWithAdjacentLists = function (dom, listBlock) {
1733
- var sibling, node;
1734
- sibling = listBlock.nextSibling;
1489
+ const mergeWithAdjacentLists = (dom, listBlock) => {
1490
+ let node;
1491
+ let sibling = listBlock.nextSibling;
1735
1492
  if (shouldMerge(dom, listBlock, sibling)) {
1736
- while (node = sibling.firstChild) {
1493
+ const liSibling = sibling;
1494
+ while (node = liSibling.firstChild) {
1737
1495
  listBlock.appendChild(node);
1738
1496
  }
1739
- dom.remove(sibling);
1497
+ dom.remove(liSibling);
1740
1498
  }
1741
1499
  sibling = listBlock.previousSibling;
1742
1500
  if (shouldMerge(dom, listBlock, sibling)) {
1743
- while (node = sibling.lastChild) {
1501
+ const liSibling = sibling;
1502
+ while (node = liSibling.lastChild) {
1744
1503
  listBlock.insertBefore(node, listBlock.firstChild);
1745
1504
  }
1746
- dom.remove(sibling);
1505
+ dom.remove(liSibling);
1747
1506
  }
1748
1507
  };
1749
- var updateList$1 = function (editor, list, listName, detail) {
1508
+ const updateList$1 = (editor, list, listName, detail) => {
1750
1509
  if (list.nodeName !== listName) {
1751
- var newList = editor.dom.rename(list, listName);
1510
+ const newList = editor.dom.rename(list, listName);
1752
1511
  updateListWithDetails(editor.dom, newList, detail);
1753
1512
  fireListEvent(editor, listToggleActionFromListName(listName), newList);
1754
1513
  } else {
@@ -1756,24 +1515,46 @@
1756
1515
  fireListEvent(editor, listToggleActionFromListName(listName), list);
1757
1516
  }
1758
1517
  };
1759
- var toggleMultipleLists = function (editor, parentList, lists, listName, detail) {
1760
- var parentIsList = isListNode(parentList);
1761
- if (parentIsList && parentList.nodeName === listName && !hasListStyleDetail(detail)) {
1518
+ const updateCustomList = (editor, list, listName, detail) => {
1519
+ list.classList.forEach((cls, _, classList) => {
1520
+ if (cls.startsWith('tox-')) {
1521
+ classList.remove(cls);
1522
+ if (classList.length === 0) {
1523
+ list.removeAttribute('class');
1524
+ }
1525
+ }
1526
+ });
1527
+ if (list.nodeName !== listName) {
1528
+ const newList = editor.dom.rename(list, listName);
1529
+ updateListWithDetails(editor.dom, newList, detail);
1530
+ fireListEvent(editor, listToggleActionFromListName(listName), newList);
1531
+ } else {
1532
+ updateListWithDetails(editor.dom, list, detail);
1533
+ fireListEvent(editor, listToggleActionFromListName(listName), list);
1534
+ }
1535
+ };
1536
+ const toggleMultipleLists = (editor, parentList, lists, listName, detail) => {
1537
+ const parentIsList = isListNode(parentList);
1538
+ if (parentIsList && parentList.nodeName === listName && !hasListStyleDetail(detail) && !isCustomList(parentList)) {
1762
1539
  flattenListSelection(editor);
1763
1540
  } else {
1764
1541
  applyList(editor, listName, detail);
1765
- var bookmark = createBookmark(editor.selection.getRng());
1766
- var allLists = parentIsList ? __spreadArray([parentList], lists, true) : lists;
1767
- global$2.each(allLists, function (elm) {
1768
- updateList$1(editor, elm, listName, detail);
1542
+ const bookmark = createBookmark(editor.selection.getRng());
1543
+ const allLists = parentIsList ? [
1544
+ parentList,
1545
+ ...lists
1546
+ ] : lists;
1547
+ const updateFunction = parentIsList && isCustomList(parentList) ? updateCustomList : updateList$1;
1548
+ global$2.each(allLists, elm => {
1549
+ updateFunction(editor, elm, listName, detail);
1769
1550
  });
1770
1551
  editor.selection.setRng(resolveBookmark(bookmark));
1771
1552
  }
1772
1553
  };
1773
- var hasListStyleDetail = function (detail) {
1554
+ const hasListStyleDetail = detail => {
1774
1555
  return 'list-style-type' in detail;
1775
1556
  };
1776
- var toggleSingleList = function (editor, parentList, listName, detail) {
1557
+ const toggleSingleList = (editor, parentList, listName, detail) => {
1777
1558
  if (parentList === editor.getBody()) {
1778
1559
  return;
1779
1560
  }
@@ -1781,9 +1562,19 @@
1781
1562
  if (parentList.nodeName === listName && !hasListStyleDetail(detail) && !isCustomList(parentList)) {
1782
1563
  flattenListSelection(editor);
1783
1564
  } else {
1784
- var bookmark = createBookmark(editor.selection.getRng());
1565
+ const bookmark = createBookmark(editor.selection.getRng());
1566
+ if (isCustomList(parentList)) {
1567
+ parentList.classList.forEach((cls, _, classList) => {
1568
+ if (cls.startsWith('tox-')) {
1569
+ classList.remove(cls);
1570
+ if (classList.length === 0) {
1571
+ parentList.removeAttribute('class');
1572
+ }
1573
+ }
1574
+ });
1575
+ }
1785
1576
  updateListWithDetails(editor.dom, parentList, detail);
1786
- var newList = editor.dom.rename(parentList, listName);
1577
+ const newList = editor.dom.rename(parentList, listName);
1787
1578
  mergeWithAdjacentLists(editor.dom, newList);
1788
1579
  editor.selection.setRng(resolveBookmark(bookmark));
1789
1580
  applyList(editor, listName, detail);
@@ -1794,10 +1585,13 @@
1794
1585
  fireListEvent(editor, listToggleActionFromListName(listName), parentList);
1795
1586
  }
1796
1587
  };
1797
- var toggleList = function (editor, listName, _detail) {
1798
- var parentList = getParentList(editor);
1799
- var selectedSubLists = getSelectedSubLists(editor);
1800
- var detail = isObject(_detail) ? _detail : {};
1588
+ const toggleList = (editor, listName, _detail) => {
1589
+ const parentList = getParentList(editor);
1590
+ if (isWithinNonEditableList(editor, parentList)) {
1591
+ return;
1592
+ }
1593
+ const selectedSubLists = getSelectedSubLists(editor);
1594
+ const detail = isObject(_detail) ? _detail : {};
1801
1595
  if (selectedSubLists.length > 0) {
1802
1596
  toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
1803
1597
  } else {
@@ -1805,14 +1599,14 @@
1805
1599
  }
1806
1600
  };
1807
1601
 
1808
- var DOM = global$3.DOM;
1809
- var normalizeList = function (dom, list) {
1810
- var parentNode = list.parentNode;
1811
- if (parentNode.nodeName === 'LI' && parentNode.firstChild === list) {
1812
- var sibling = parentNode.previousSibling;
1602
+ const DOM = global$3.DOM;
1603
+ const normalizeList = (dom, list) => {
1604
+ const parentNode = list.parentElement;
1605
+ if (parentNode && parentNode.nodeName === 'LI' && parentNode.firstChild === list) {
1606
+ const sibling = parentNode.previousSibling;
1813
1607
  if (sibling && sibling.nodeName === 'LI') {
1814
1608
  sibling.appendChild(list);
1815
- if (isEmpty(dom, parentNode)) {
1609
+ if (isEmpty$2(dom, parentNode)) {
1816
1610
  DOM.remove(parentNode);
1817
1611
  }
1818
1612
  } else {
@@ -1820,69 +1614,72 @@
1820
1614
  }
1821
1615
  }
1822
1616
  if (isListNode(parentNode)) {
1823
- var sibling = parentNode.previousSibling;
1617
+ const sibling = parentNode.previousSibling;
1824
1618
  if (sibling && sibling.nodeName === 'LI') {
1825
1619
  sibling.appendChild(list);
1826
1620
  }
1827
1621
  }
1828
1622
  };
1829
- var normalizeLists = function (dom, element) {
1830
- var lists = global$2.grep(dom.select('ol,ul', element));
1831
- global$2.each(lists, function (list) {
1623
+ const normalizeLists = (dom, element) => {
1624
+ const lists = global$2.grep(dom.select('ol,ul', element));
1625
+ global$2.each(lists, list => {
1832
1626
  normalizeList(dom, list);
1833
1627
  });
1834
1628
  };
1835
1629
 
1836
- var findNextCaretContainer = function (editor, rng, isForward, root) {
1837
- var node = rng.startContainer;
1838
- var offset = rng.startOffset;
1839
- if (isTextNode(node) && (isForward ? offset < node.data.length : offset > 0)) {
1630
+ const findNextCaretContainer = (editor, rng, isForward, root) => {
1631
+ let node = rng.startContainer;
1632
+ const offset = rng.startOffset;
1633
+ if (isTextNode$1(node) && (isForward ? offset < node.data.length : offset > 0)) {
1840
1634
  return node;
1841
1635
  }
1842
- var nonEmptyBlocks = editor.schema.getNonEmptyElements();
1843
- if (node.nodeType === 1) {
1636
+ const nonEmptyBlocks = editor.schema.getNonEmptyElements();
1637
+ if (isElement(node)) {
1844
1638
  node = global$6.getNode(node, offset);
1845
1639
  }
1846
- var walker = new global$5(node, root);
1640
+ const walker = new global$5(node, root);
1847
1641
  if (isForward) {
1848
1642
  if (isBogusBr(editor.dom, node)) {
1849
1643
  walker.next();
1850
1644
  }
1851
1645
  }
1852
- while (node = walker[isForward ? 'next' : 'prev2']()) {
1646
+ const walkFn = isForward ? walker.next.bind(walker) : walker.prev2.bind(walker);
1647
+ while (node = walkFn()) {
1853
1648
  if (node.nodeName === 'LI' && !node.hasChildNodes()) {
1854
1649
  return node;
1855
1650
  }
1856
1651
  if (nonEmptyBlocks[node.nodeName]) {
1857
1652
  return node;
1858
1653
  }
1859
- if (isTextNode(node) && node.data.length > 0) {
1654
+ if (isTextNode$1(node) && node.data.length > 0) {
1860
1655
  return node;
1861
1656
  }
1862
1657
  }
1658
+ return null;
1863
1659
  };
1864
- var hasOnlyOneBlockChild = function (dom, elm) {
1865
- var childNodes = elm.childNodes;
1660
+ const hasOnlyOneBlockChild = (dom, elm) => {
1661
+ const childNodes = elm.childNodes;
1866
1662
  return childNodes.length === 1 && !isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
1867
1663
  };
1868
- var unwrapSingleBlockChild = function (dom, elm) {
1869
- if (hasOnlyOneBlockChild(dom, elm)) {
1664
+ const isUnwrappable = node => Optional.from(node).map(SugarElement.fromDom).filter(isHTMLElement).exists(el => isEditable(el) && !contains$1(['details'], name(el)));
1665
+ const unwrapSingleBlockChild = (dom, elm) => {
1666
+ if (hasOnlyOneBlockChild(dom, elm) && isUnwrappable(elm.firstChild)) {
1870
1667
  dom.remove(elm.firstChild, true);
1871
1668
  }
1872
1669
  };
1873
- var moveChildren = function (dom, fromElm, toElm) {
1874
- var node;
1875
- var targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
1670
+ const moveChildren = (dom, fromElm, toElm) => {
1671
+ let node;
1672
+ const targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
1876
1673
  unwrapSingleBlockChild(dom, fromElm);
1877
- if (!isEmpty(dom, fromElm, true)) {
1674
+ if (!isEmpty$2(dom, fromElm, true)) {
1878
1675
  while (node = fromElm.firstChild) {
1879
1676
  targetElm.appendChild(node);
1880
1677
  }
1881
1678
  }
1882
1679
  };
1883
- var mergeLiElements = function (dom, fromElm, toElm) {
1884
- var listNode;
1885
- var ul = fromElm.parentNode;
1680
+ const mergeLiElements = (dom, fromElm, toElm) => {
1681
+ let listNode;
1682
+ const ul = fromElm.parentNode;
1886
1683
  if (!isChildOfBody(dom, fromElm) || !isChildOfBody(dom, toElm)) {
1887
1684
  return;
1888
1685
  }
@@ -1894,75 +1691,88 @@
1894
1691
  dom.remove(ul.previousSibling);
1895
1692
  }
1896
1693
  }
1897
- var node = toElm.lastChild;
1694
+ const node = toElm.lastChild;
1898
1695
  if (node && isBr(node) && fromElm.hasChildNodes()) {
1899
1696
  dom.remove(node);
1900
1697
  }
1901
- if (isEmpty(dom, toElm, true)) {
1902
- dom.$(toElm).empty();
1698
+ if (isEmpty$2(dom, toElm, true)) {
1699
+ empty(SugarElement.fromDom(toElm));
1903
1700
  }
1904
1701
  moveChildren(dom, fromElm, toElm);
1905
1702
  if (listNode) {
1906
1703
  toElm.appendChild(listNode);
1907
1704
  }
1908
- var contains$1 = contains(SugarElement.fromDom(toElm), SugarElement.fromDom(fromElm));
1909
- var nestedLists = contains$1 ? dom.getParents(fromElm, isListNode, toElm) : [];
1705
+ const contains$1 = contains(SugarElement.fromDom(toElm), SugarElement.fromDom(fromElm));
1706
+ const nestedLists = contains$1 ? dom.getParents(fromElm, isListNode, toElm) : [];
1910
1707
  dom.remove(fromElm);
1911
- each$1(nestedLists, function (list) {
1912
- if (isEmpty(dom, list) && list !== dom.getRoot()) {
1708
+ each$1(nestedLists, list => {
1709
+ if (isEmpty$2(dom, list) && list !== dom.getRoot()) {
1913
1710
  dom.remove(list);
1914
1711
  }
1915
1712
  });
1916
1713
  };
1917
- var mergeIntoEmptyLi = function (editor, fromLi, toLi) {
1918
- editor.dom.$(toLi).empty();
1714
+ const mergeIntoEmptyLi = (editor, fromLi, toLi) => {
1715
+ empty(SugarElement.fromDom(toLi));
1919
1716
  mergeLiElements(editor.dom, fromLi, toLi);
1920
1717
  editor.selection.setCursorLocation(toLi, 0);
1921
1718
  };
1922
- var mergeForward = function (editor, rng, fromLi, toLi) {
1923
- var dom = editor.dom;
1719
+ const mergeForward = (editor, rng, fromLi, toLi) => {
1720
+ const dom = editor.dom;
1924
1721
  if (dom.isEmpty(toLi)) {
1925
1722
  mergeIntoEmptyLi(editor, fromLi, toLi);
1926
1723
  } else {
1927
- var bookmark = createBookmark(rng);
1724
+ const bookmark = createBookmark(rng);
1928
1725
  mergeLiElements(dom, fromLi, toLi);
1929
1726
  editor.selection.setRng(resolveBookmark(bookmark));
1930
1727
  }
1931
1728
  };
1932
- var mergeBackward = function (editor, rng, fromLi, toLi) {
1933
- var bookmark = createBookmark(rng);
1729
+ const mergeBackward = (editor, rng, fromLi, toLi) => {
1730
+ const bookmark = createBookmark(rng);
1934
1731
  mergeLiElements(editor.dom, fromLi, toLi);
1935
- var resolvedBookmark = resolveBookmark(bookmark);
1732
+ const resolvedBookmark = resolveBookmark(bookmark);
1936
1733
  editor.selection.setRng(resolvedBookmark);
1937
1734
  };
1938
- var backspaceDeleteFromListToListCaret = function (editor, isForward) {
1939
- var dom = editor.dom, selection = editor.selection;
1940
- var selectionStartElm = selection.getStart();
1941
- var root = getClosestListRootElm(editor, selectionStartElm);
1942
- var li = dom.getParent(selection.getStart(), 'LI', root);
1735
+ const backspaceDeleteFromListToListCaret = (editor, isForward) => {
1736
+ const dom = editor.dom, selection = editor.selection;
1737
+ const selectionStartElm = selection.getStart();
1738
+ const root = getClosestEditingHost(editor, selectionStartElm);
1739
+ const li = dom.getParent(selection.getStart(), 'LI', root);
1943
1740
  if (li) {
1944
- var ul = li.parentNode;
1945
- if (ul === editor.getBody() && isEmpty(dom, ul)) {
1741
+ const ul = li.parentElement;
1742
+ if (ul === editor.getBody() && isEmpty$2(dom, ul)) {
1946
1743
  return true;
1947
1744
  }
1948
- var rng_1 = normalizeRange(selection.getRng());
1949
- var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng_1, isForward, root), 'LI', root);
1950
- if (otherLi_1 && otherLi_1 !== li) {
1951
- editor.undoManager.transact(function () {
1745
+ const rng = normalizeRange(selection.getRng());
1746
+ const otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1747
+ const willMergeParentIntoChild = otherLi && (isForward ? dom.isChildOf(li, otherLi) : dom.isChildOf(otherLi, li));
1748
+ if (otherLi && otherLi !== li && !willMergeParentIntoChild) {
1749
+ editor.undoManager.transact(() => {
1952
1750
  if (isForward) {
1953
- mergeForward(editor, rng_1, otherLi_1, li);
1751
+ mergeForward(editor, rng, otherLi, li);
1954
1752
  } else {
1955
1753
  if (isFirstChild(li)) {
1956
1754
  outdentListSelection(editor);
1957
1755
  } else {
1958
- mergeBackward(editor, rng_1, li, otherLi_1);
1756
+ mergeBackward(editor, rng, li, otherLi);
1959
1757
  }
1960
1758
  }
1961
1759
  });
1962
1760
  return true;
1963
- } else if (!otherLi_1) {
1964
- if (!isForward && rng_1.startOffset === 0 && rng_1.endOffset === 0) {
1965
- editor.undoManager.transact(function () {
1761
+ } else if (willMergeParentIntoChild && !isForward && otherLi !== li) {
1762
+ editor.undoManager.transact(() => {
1763
+ if (rng.commonAncestorContainer.parentElement) {
1764
+ const bookmark = createBookmark(rng);
1765
+ const oldParentElRef = rng.commonAncestorContainer.parentElement;
1766
+ moveChildren(dom, rng.commonAncestorContainer.parentElement, otherLi);
1767
+ oldParentElRef.remove();
1768
+ const resolvedBookmark = resolveBookmark(bookmark);
1769
+ editor.selection.setRng(resolvedBookmark);
1770
+ }
1771
+ });
1772
+ return true;
1773
+ } else if (!otherLi) {
1774
+ if (!isForward && rng.startOffset === 0 && rng.endOffset === 0) {
1775
+ editor.undoManager.transact(() => {
1966
1776
  flattenListSelection(editor);
1967
1777
  });
1968
1778
  return true;
@@ -1971,26 +1781,38 @@
1971
1781
  }
1972
1782
  return false;
1973
1783
  };
1974
- var removeBlock = function (dom, block, root) {
1975
- var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
1784
+ const removeBlock = (dom, block, root) => {
1785
+ const parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
1976
1786
  dom.remove(block);
1977
1787
  if (parentBlock && dom.isEmpty(parentBlock)) {
1978
1788
  dom.remove(parentBlock);
1979
1789
  }
1980
1790
  };
1981
- var backspaceDeleteIntoListCaret = function (editor, isForward) {
1982
- var dom = editor.dom;
1983
- var selectionStartElm = editor.selection.getStart();
1984
- var root = getClosestListRootElm(editor, selectionStartElm);
1985
- var block = dom.getParent(selectionStartElm, dom.isBlock, root);
1986
- if (block && dom.isEmpty(block)) {
1987
- var rng = normalizeRange(editor.selection.getRng());
1988
- var otherLi_2 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1989
- if (otherLi_2) {
1990
- editor.undoManager.transact(function () {
1791
+ const backspaceDeleteIntoListCaret = (editor, isForward) => {
1792
+ const dom = editor.dom;
1793
+ const selectionStartElm = editor.selection.getStart();
1794
+ const root = getClosestEditingHost(editor, selectionStartElm);
1795
+ const block = dom.getParent(selectionStartElm, dom.isBlock, root);
1796
+ if (block && dom.isEmpty(block, undefined, { checkRootAsContent: true })) {
1797
+ const rng = normalizeRange(editor.selection.getRng());
1798
+ const otherLi = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
1799
+ if (otherLi) {
1800
+ const findValidElement = element => contains$1([
1801
+ 'td',
1802
+ 'th',
1803
+ 'caption'
1804
+ ], name(element));
1805
+ const findRoot = node => node.dom === root;
1806
+ const otherLiCell = closest$2(SugarElement.fromDom(otherLi), findValidElement, findRoot);
1807
+ const caretCell = closest$2(SugarElement.fromDom(rng.startContainer), findValidElement, findRoot);
1808
+ if (!equals(otherLiCell, caretCell, eq)) {
1809
+ return false;
1810
+ }
1811
+ editor.undoManager.transact(() => {
1812
+ const parentNode = otherLi.parentNode;
1991
1813
  removeBlock(dom, block, root);
1992
- mergeWithAdjacentLists(dom, otherLi_2.parentNode);
1993
- editor.selection.select(otherLi_2, true);
1814
+ mergeWithAdjacentLists(dom, parentNode);
1815
+ editor.selection.select(otherLi, true);
1994
1816
  editor.selection.collapse(isForward);
1995
1817
  });
1996
1818
  return true;
@@ -1998,15 +1820,18 @@
1998
1820
  }
1999
1821
  return false;
2000
1822
  };
2001
- var backspaceDeleteCaret = function (editor, isForward) {
1823
+ const backspaceDeleteCaret = (editor, isForward) => {
2002
1824
  return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
2003
1825
  };
2004
- var backspaceDeleteRange = function (editor) {
2005
- var selectionStartElm = editor.selection.getStart();
2006
- var root = getClosestListRootElm(editor, selectionStartElm);
2007
- var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
2008
- if (startListParent || getSelectedListItems(editor).length > 0) {
2009
- editor.undoManager.transact(function () {
1826
+ const hasListSelection = editor => {
1827
+ const selectionStartElm = editor.selection.getStart();
1828
+ const root = getClosestEditingHost(editor, selectionStartElm);
1829
+ const startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
1830
+ return startListParent || getSelectedListItems(editor).length > 0;
1831
+ };
1832
+ const backspaceDeleteRange = editor => {
1833
+ if (hasListSelection(editor)) {
1834
+ editor.undoManager.transact(() => {
2010
1835
  editor.execCommand('Delete');
2011
1836
  normalizeLists(editor.dom, editor.getBody());
2012
1837
  });
@@ -2014,11 +1839,18 @@
2014
1839
  }
2015
1840
  return false;
2016
1841
  };
2017
- var backspaceDelete = function (editor, isForward) {
2018
- return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
1842
+ const backspaceDelete = (editor, isForward) => {
1843
+ const selection = editor.selection;
1844
+ return !isWithinNonEditableList(editor, selection.getNode()) && (selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor));
2019
1845
  };
2020
- var setup$1 = function (editor) {
2021
- editor.on('keydown', function (e) {
1846
+ const setup$2 = editor => {
1847
+ editor.on('ExecCommand', e => {
1848
+ const cmd = e.command.toLowerCase();
1849
+ if ((cmd === 'delete' || cmd === 'forwarddelete') && hasListSelection(editor)) {
1850
+ normalizeLists(editor.dom, editor.getBody());
1851
+ }
1852
+ });
1853
+ editor.on('keydown', e => {
2022
1854
  if (e.keyCode === global$4.BACKSPACE) {
2023
1855
  if (backspaceDelete(editor, false)) {
2024
1856
  e.preventDefault();
@@ -2031,60 +1863,51 @@
2031
1863
  });
2032
1864
  };
2033
1865
 
2034
- var get = function (editor) {
2035
- return {
2036
- backspaceDelete: function (isForward) {
2037
- backspaceDelete(editor, isForward);
2038
- }
2039
- };
2040
- };
1866
+ const get = editor => ({
1867
+ backspaceDelete: isForward => {
1868
+ backspaceDelete(editor, isForward);
1869
+ }
1870
+ });
2041
1871
 
2042
- var updateList = function (editor, update) {
2043
- var parentList = getParentList(editor);
2044
- editor.undoManager.transact(function () {
1872
+ const updateList = (editor, update) => {
1873
+ const parentList = getParentList(editor);
1874
+ if (parentList === null || isWithinNonEditableList(editor, parentList)) {
1875
+ return;
1876
+ }
1877
+ editor.undoManager.transact(() => {
2045
1878
  if (isObject(update.styles)) {
2046
1879
  editor.dom.setStyles(parentList, update.styles);
2047
1880
  }
2048
1881
  if (isObject(update.attrs)) {
2049
- each(update.attrs, function (v, k) {
2050
- return editor.dom.setAttrib(parentList, k, v);
2051
- });
1882
+ each(update.attrs, (v, k) => editor.dom.setAttrib(parentList, k, v));
2052
1883
  }
2053
1884
  });
2054
1885
  };
2055
1886
 
2056
- var parseAlphabeticBase26 = function (str) {
2057
- var chars = reverse(trim(str).split(''));
2058
- var values = map(chars, function (char, i) {
2059
- var charValue = char.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
1887
+ const parseAlphabeticBase26 = str => {
1888
+ const chars = reverse(trim(str).split(''));
1889
+ const values = map(chars, (char, i) => {
1890
+ const charValue = char.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
2060
1891
  return Math.pow(26, i) * charValue;
2061
1892
  });
2062
- return foldl(values, function (sum, v) {
2063
- return sum + v;
2064
- }, 0);
1893
+ return foldl(values, (sum, v) => sum + v, 0);
2065
1894
  };
2066
- var composeAlphabeticBase26 = function (value) {
1895
+ const composeAlphabeticBase26 = value => {
2067
1896
  value--;
2068
1897
  if (value < 0) {
2069
1898
  return '';
2070
1899
  } else {
2071
- var remainder = value % 26;
2072
- var quotient = Math.floor(value / 26);
2073
- var rest = composeAlphabeticBase26(quotient);
2074
- var char = String.fromCharCode('A'.charCodeAt(0) + remainder);
1900
+ const remainder = value % 26;
1901
+ const quotient = Math.floor(value / 26);
1902
+ const rest = composeAlphabeticBase26(quotient);
1903
+ const char = String.fromCharCode('A'.charCodeAt(0) + remainder);
2075
1904
  return rest + char;
2076
1905
  }
2077
1906
  };
2078
- var isUppercase = function (str) {
2079
- return /^[A-Z]+$/.test(str);
2080
- };
2081
- var isLowercase = function (str) {
2082
- return /^[a-z]+$/.test(str);
2083
- };
2084
- var isNumeric = function (str) {
2085
- return /^[0-9]+$/.test(str);
2086
- };
2087
- var deduceListType = function (start) {
1907
+ const isUppercase = str => /^[A-Z]+$/.test(str);
1908
+ const isLowercase = str => /^[a-z]+$/.test(str);
1909
+ const isNumeric = str => /^[0-9]+$/.test(str);
1910
+ const deduceListType = start => {
2088
1911
  if (isNumeric(start)) {
2089
1912
  return 2;
2090
1913
  } else if (isUppercase(start)) {
@@ -2097,12 +1920,12 @@
2097
1920
  return 4;
2098
1921
  }
2099
1922
  };
2100
- var parseStartValue = function (start) {
1923
+ const parseStartValue = start => {
2101
1924
  switch (deduceListType(start)) {
2102
1925
  case 2:
2103
1926
  return Optional.some({
2104
1927
  listStyleType: Optional.none(),
2105
- start: start
1928
+ start
2106
1929
  });
2107
1930
  case 0:
2108
1931
  return Optional.some({
@@ -2123,20 +1946,20 @@
2123
1946
  return Optional.none();
2124
1947
  }
2125
1948
  };
2126
- var parseDetail = function (detail) {
2127
- var start = parseInt(detail.start, 10);
2128
- if (is(detail.listStyleType, 'upper-alpha')) {
1949
+ const parseDetail = detail => {
1950
+ const start = parseInt(detail.start, 10);
1951
+ if (is$2(detail.listStyleType, 'upper-alpha')) {
2129
1952
  return composeAlphabeticBase26(start);
2130
- } else if (is(detail.listStyleType, 'lower-alpha')) {
1953
+ } else if (is$2(detail.listStyleType, 'lower-alpha')) {
2131
1954
  return composeAlphabeticBase26(start).toLowerCase();
2132
1955
  } else {
2133
1956
  return detail.start;
2134
1957
  }
2135
1958
  };
2136
1959
 
2137
- var open = function (editor) {
2138
- var currentList = getParentList(editor);
2139
- if (!isOlNode(currentList)) {
1960
+ const open = editor => {
1961
+ const currentList = getParentList(editor);
1962
+ if (!isOlNode(currentList) || isWithinNonEditableList(editor, currentList)) {
2140
1963
  return;
2141
1964
  }
2142
1965
  editor.windowManager.open({
@@ -2153,7 +1976,7 @@
2153
1976
  initialData: {
2154
1977
  start: parseDetail({
2155
1978
  start: editor.dom.getAttrib(currentList, 'start', '1'),
2156
- listStyleType: Optional.some(editor.dom.getStyle(currentList, 'list-style-type'))
1979
+ listStyleType: Optional.from(editor.dom.getStyle(currentList, 'list-style-type'))
2157
1980
  })
2158
1981
  },
2159
1982
  buttons: [
@@ -2169,9 +1992,9 @@
2169
1992
  primary: true
2170
1993
  }
2171
1994
  ],
2172
- onSubmit: function (api) {
2173
- var data = api.getData();
2174
- parseStartValue(data.start).each(function (detail) {
1995
+ onSubmit: api => {
1996
+ const data = api.getData();
1997
+ parseStartValue(data.start).each(detail => {
2175
1998
  editor.execCommand('mceListUpdate', false, {
2176
1999
  attrs: { start: detail.start === '1' ? '' : detail.start },
2177
2000
  styles: { 'list-style-type': detail.listStyleType.getOr('') }
@@ -2182,40 +2005,38 @@
2182
2005
  });
2183
2006
  };
2184
2007
 
2185
- var queryListCommandState = function (editor, listName) {
2186
- return function () {
2187
- var parentList = getParentList(editor);
2188
- return parentList && parentList.nodeName === listName;
2189
- };
2008
+ const queryListCommandState = (editor, listName) => () => {
2009
+ const parentList = getParentList(editor);
2010
+ return isNonNullable(parentList) && parentList.nodeName === listName;
2190
2011
  };
2191
- var registerDialog = function (editor) {
2192
- editor.addCommand('mceListProps', function () {
2012
+ const registerDialog = editor => {
2013
+ editor.addCommand('mceListProps', () => {
2193
2014
  open(editor);
2194
2015
  });
2195
2016
  };
2196
- var register$2 = function (editor) {
2197
- editor.on('BeforeExecCommand', function (e) {
2198
- var cmd = e.command.toLowerCase();
2017
+ const register$2 = editor => {
2018
+ editor.on('BeforeExecCommand', e => {
2019
+ const cmd = e.command.toLowerCase();
2199
2020
  if (cmd === 'indent') {
2200
2021
  indentListSelection(editor);
2201
2022
  } else if (cmd === 'outdent') {
2202
2023
  outdentListSelection(editor);
2203
2024
  }
2204
2025
  });
2205
- editor.addCommand('InsertUnorderedList', function (ui, detail) {
2026
+ editor.addCommand('InsertUnorderedList', (ui, detail) => {
2206
2027
  toggleList(editor, 'UL', detail);
2207
2028
  });
2208
- editor.addCommand('InsertOrderedList', function (ui, detail) {
2029
+ editor.addCommand('InsertOrderedList', (ui, detail) => {
2209
2030
  toggleList(editor, 'OL', detail);
2210
2031
  });
2211
- editor.addCommand('InsertDefinitionList', function (ui, detail) {
2032
+ editor.addCommand('InsertDefinitionList', (ui, detail) => {
2212
2033
  toggleList(editor, 'DL', detail);
2213
2034
  });
2214
- editor.addCommand('RemoveList', function () {
2035
+ editor.addCommand('RemoveList', () => {
2215
2036
  flattenListSelection(editor);
2216
2037
  });
2217
2038
  registerDialog(editor);
2218
- editor.addCommand('mceListUpdate', function (ui, detail) {
2039
+ editor.addCommand('mceListUpdate', (ui, detail) => {
2219
2040
  if (isObject(detail)) {
2220
2041
  updateList(editor, detail);
2221
2042
  }
@@ -2225,78 +2046,117 @@
2225
2046
  editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
2226
2047
  };
2227
2048
 
2228
- var setupTabKey = function (editor) {
2229
- editor.on('keydown', function (e) {
2049
+ var global = tinymce.util.Tools.resolve('tinymce.html.Node');
2050
+
2051
+ const isTextNode = node => node.type === 3;
2052
+ const isEmpty = nodeBuffer => nodeBuffer.length === 0;
2053
+ const wrapInvalidChildren = list => {
2054
+ const insertListItem = (buffer, refNode) => {
2055
+ const li = global.create('li');
2056
+ each$1(buffer, node => li.append(node));
2057
+ if (refNode) {
2058
+ list.insert(li, refNode, true);
2059
+ } else {
2060
+ list.append(li);
2061
+ }
2062
+ };
2063
+ const reducer = (buffer, node) => {
2064
+ if (isTextNode(node)) {
2065
+ return [
2066
+ ...buffer,
2067
+ node
2068
+ ];
2069
+ } else if (!isEmpty(buffer) && !isTextNode(node)) {
2070
+ insertListItem(buffer, node);
2071
+ return [];
2072
+ } else {
2073
+ return buffer;
2074
+ }
2075
+ };
2076
+ const restBuffer = foldl(list.children(), reducer, []);
2077
+ if (!isEmpty(restBuffer)) {
2078
+ insertListItem(restBuffer);
2079
+ }
2080
+ };
2081
+ const setup$1 = editor => {
2082
+ editor.on('PreInit', () => {
2083
+ const {parser} = editor;
2084
+ parser.addNodeFilter('ul,ol', nodes => each$1(nodes, wrapInvalidChildren));
2085
+ });
2086
+ };
2087
+
2088
+ const setupTabKey = editor => {
2089
+ editor.on('keydown', e => {
2230
2090
  if (e.keyCode !== global$4.TAB || global$4.metaKeyPressed(e)) {
2231
2091
  return;
2232
2092
  }
2233
- editor.undoManager.transact(function () {
2093
+ editor.undoManager.transact(() => {
2234
2094
  if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
2235
2095
  e.preventDefault();
2236
2096
  }
2237
2097
  });
2238
2098
  });
2239
2099
  };
2240
- var setup = function (editor) {
2100
+ const setup = editor => {
2241
2101
  if (shouldIndentOnTab(editor)) {
2242
2102
  setupTabKey(editor);
2243
2103
  }
2244
- setup$1(editor);
2104
+ setup$2(editor);
2245
2105
  };
2246
2106
 
2247
- var register$1 = function (editor) {
2248
- var exec = function (command) {
2249
- return function () {
2250
- return editor.execCommand(command);
2251
- };
2107
+ const setupToggleButtonHandler = (editor, listName) => api => {
2108
+ const toggleButtonHandler = e => {
2109
+ api.setActive(inList(e.parents, listName));
2110
+ api.setEnabled(!isWithinNonEditableList(editor, e.element) && editor.selection.isEditable());
2252
2111
  };
2112
+ api.setEnabled(editor.selection.isEditable());
2113
+ return setNodeChangeHandler(editor, toggleButtonHandler);
2114
+ };
2115
+ const register$1 = editor => {
2116
+ const exec = command => () => editor.execCommand(command);
2253
2117
  if (!editor.hasPlugin('advlist')) {
2254
2118
  editor.ui.registry.addToggleButton('numlist', {
2255
2119
  icon: 'ordered-list',
2256
2120
  active: false,
2257
2121
  tooltip: 'Numbered list',
2258
2122
  onAction: exec('InsertOrderedList'),
2259
- onSetup: function (api) {
2260
- return listState(editor, 'OL', api.setActive);
2261
- }
2123
+ onSetup: setupToggleButtonHandler(editor, 'OL')
2262
2124
  });
2263
2125
  editor.ui.registry.addToggleButton('bullist', {
2264
2126
  icon: 'unordered-list',
2265
2127
  active: false,
2266
2128
  tooltip: 'Bullet list',
2267
2129
  onAction: exec('InsertUnorderedList'),
2268
- onSetup: function (api) {
2269
- return listState(editor, 'UL', api.setActive);
2270
- }
2130
+ onSetup: setupToggleButtonHandler(editor, 'UL')
2271
2131
  });
2272
2132
  }
2273
2133
  };
2274
2134
 
2275
- var register = function (editor) {
2276
- var listProperties = {
2135
+ const setupMenuButtonHandler = (editor, listName) => api => {
2136
+ const menuButtonHandler = e => api.setEnabled(inList(e.parents, listName) && !isWithinNonEditableList(editor, e.element));
2137
+ return setNodeChangeHandler(editor, menuButtonHandler);
2138
+ };
2139
+ const register = editor => {
2140
+ const listProperties = {
2277
2141
  text: 'List properties...',
2278
2142
  icon: 'ordered-list',
2279
- onAction: function () {
2280
- return editor.execCommand('mceListProps');
2281
- },
2282
- onSetup: function (api) {
2283
- return listState(editor, 'OL', function (active) {
2284
- return api.setDisabled(!active);
2285
- });
2286
- }
2143
+ onAction: () => editor.execCommand('mceListProps'),
2144
+ onSetup: setupMenuButtonHandler(editor, 'OL')
2287
2145
  };
2288
2146
  editor.ui.registry.addMenuItem('listprops', listProperties);
2289
2147
  editor.ui.registry.addContextMenu('lists', {
2290
- update: function (node) {
2291
- var parentList = getParentList(editor, node);
2148
+ update: node => {
2149
+ const parentList = getParentList(editor, node);
2292
2150
  return isOlNode(parentList) ? ['listprops'] : [];
2293
2151
  }
2294
2152
  });
2295
2153
  };
2296
2154
 
2297
- function Plugin () {
2298
- global$7.add('lists', function (editor) {
2299
- if (editor.hasPlugin('rtc', true) === false) {
2155
+ var Plugin = () => {
2156
+ global$7.add('lists', editor => {
2157
+ register$3(editor);
2158
+ setup$1(editor);
2159
+ if (!editor.hasPlugin('rtc', true)) {
2300
2160
  setup(editor);
2301
2161
  register$2(editor);
2302
2162
  } else {
@@ -2306,8 +2166,8 @@
2306
2166
  register(editor);
2307
2167
  return get(editor);
2308
2168
  });
2309
- }
2169
+ };
2310
2170
 
2311
2171
  Plugin();
2312
2172
 
2313
- }());
2173
+ })();