@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.
- package/README.md +1 -7
- package/esm2022/lib/angular-material-shared.module.mjs +2 -2
- package/esm2022/lib/components/tiny-mce/tiny-mce.component.mjs +16 -19
- package/fesm2022/dangl-angular-material-shared.mjs +16 -19
- package/fesm2022/dangl-angular-material-shared.mjs.map +1 -1
- package/lib/components/tiny-mce/tiny-mce.component.d.ts +7 -8
- package/package.json +1 -1
- package/tinymce-assets/icons/default/icons.js +187 -171
- package/tinymce-assets/icons/default/icons.min.js +1 -1
- package/tinymce-assets/langs/it.js +1 -1
- package/tinymce-assets/plugins/accordion/index.js +7 -0
- package/tinymce-assets/plugins/accordion/plugin.js +1054 -0
- package/tinymce-assets/plugins/accordion/plugin.min.js +4 -0
- package/tinymce-assets/plugins/advlist/plugin.js +185 -187
- package/tinymce-assets/plugins/advlist/plugin.min.js +2 -7
- package/tinymce-assets/plugins/anchor/plugin.js +79 -81
- package/tinymce-assets/plugins/anchor/plugin.min.js +2 -7
- package/tinymce-assets/plugins/autolink/plugin.js +209 -194
- package/tinymce-assets/plugins/autolink/plugin.min.js +2 -7
- package/tinymce-assets/plugins/autoresize/plugin.js +110 -102
- package/tinymce-assets/plugins/autoresize/plugin.min.js +2 -7
- package/tinymce-assets/plugins/autosave/plugin.js +125 -104
- package/tinymce-assets/plugins/autosave/plugin.min.js +2 -7
- package/tinymce-assets/plugins/charmap/plugin.js +275 -313
- package/tinymce-assets/plugins/charmap/plugin.min.js +2 -7
- package/tinymce-assets/plugins/code/plugin.js +18 -24
- package/tinymce-assets/plugins/code/plugin.min.js +2 -7
- package/tinymce-assets/plugins/codesample/plugin.js +2075 -2074
- package/tinymce-assets/plugins/codesample/plugin.min.js +2 -7
- package/tinymce-assets/plugins/directionality/plugin.js +247 -305
- package/tinymce-assets/plugins/directionality/plugin.min.js +2 -7
- package/tinymce-assets/plugins/emoticons/js/emojiimages.js +1 -9424
- package/tinymce-assets/plugins/emoticons/js/emojiimages.min.js +1 -1
- package/tinymce-assets/plugins/emoticons/js/emojis.js +1 -9423
- package/tinymce-assets/plugins/emoticons/js/emojis.min.js +1 -1
- package/tinymce-assets/plugins/emoticons/plugin.js +334 -374
- package/tinymce-assets/plugins/emoticons/plugin.min.js +2 -7
- package/tinymce-assets/plugins/fullscreen/plugin.js +740 -837
- package/tinymce-assets/plugins/fullscreen/plugin.min.js +2 -7
- package/tinymce-assets/plugins/help/js/i18n/keynav/ar.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/bg_BG.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ca.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/cs.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/da.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/de.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/el.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/en.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/es.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/eu.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/fa.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/fi.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/fr_FR.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/he_IL.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/hi.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/hr.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/hu_HU.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/id.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/it.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ja.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/kk.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ko_KR.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ms.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/nb_NO.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/nl.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/pl.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_BR.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_PT.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ro.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ru.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/sk.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/sl_SI.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/sv_SE.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/th_TH.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/tr.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/uk.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/vi.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_CN.js +84 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_TW.js +90 -0
- package/tinymce-assets/plugins/help/plugin.js +411 -355
- package/tinymce-assets/plugins/help/plugin.min.js +2 -7
- package/tinymce-assets/plugins/image/plugin.js +876 -1037
- package/tinymce-assets/plugins/image/plugin.min.js +2 -7
- package/tinymce-assets/plugins/importcss/plugin.js +146 -144
- package/tinymce-assets/plugins/importcss/plugin.min.js +2 -7
- package/tinymce-assets/plugins/insertdatetime/plugin.js +93 -88
- package/tinymce-assets/plugins/insertdatetime/plugin.min.js +2 -7
- package/tinymce-assets/plugins/link/plugin.js +718 -768
- package/tinymce-assets/plugins/link/plugin.min.js +2 -7
- package/tinymce-assets/plugins/lists/plugin.js +1235 -1375
- package/tinymce-assets/plugins/lists/plugin.min.js +2 -7
- package/tinymce-assets/plugins/media/plugin.js +614 -756
- package/tinymce-assets/plugins/media/plugin.min.js +2 -7
- package/tinymce-assets/plugins/nonbreaking/plugin.js +71 -48
- package/tinymce-assets/plugins/nonbreaking/plugin.min.js +2 -7
- package/tinymce-assets/plugins/pagebreak/plugin.js +53 -40
- package/tinymce-assets/plugins/pagebreak/plugin.min.js +2 -7
- package/tinymce-assets/plugins/preview/plugin.js +36 -65
- package/tinymce-assets/plugins/preview/plugin.min.js +2 -7
- package/tinymce-assets/plugins/quickbars/plugin.js +304 -331
- package/tinymce-assets/plugins/quickbars/plugin.min.js +2 -7
- package/tinymce-assets/plugins/save/plugin.js +49 -50
- package/tinymce-assets/plugins/save/plugin.min.js +2 -7
- package/tinymce-assets/plugins/searchreplace/plugin.js +499 -571
- package/tinymce-assets/plugins/searchreplace/plugin.min.js +2 -7
- package/tinymce-assets/plugins/table/plugin.js +2572 -10617
- package/tinymce-assets/plugins/table/plugin.min.js +2 -7
- package/tinymce-assets/plugins/visualblocks/plugin.js +41 -46
- package/tinymce-assets/plugins/visualblocks/plugin.min.js +2 -7
- package/tinymce-assets/plugins/visualchars/plugin.js +346 -312
- package/tinymce-assets/plugins/visualchars/plugin.min.js +2 -7
- package/tinymce-assets/plugins/wordcount/plugin.js +159 -179
- package/tinymce-assets/plugins/wordcount/plugin.min.js +2 -7
- package/tinymce-assets/skins/content/dark/content.css +2 -8
- package/tinymce-assets/skins/content/dark/content.js +2 -0
- package/tinymce-assets/skins/content/dark/content.min.css +1 -7
- package/tinymce-assets/skins/content/default/content.css +0 -6
- package/tinymce-assets/skins/content/default/content.js +2 -0
- package/tinymce-assets/skins/content/default/content.min.css +0 -6
- package/tinymce-assets/skins/content/document/content.css +0 -6
- package/tinymce-assets/skins/content/document/content.js +2 -0
- package/tinymce-assets/skins/content/document/content.min.css +0 -6
- package/tinymce-assets/skins/content/tinymce-5/content.css +61 -0
- package/tinymce-assets/skins/content/tinymce-5/content.js +2 -0
- package/tinymce-assets/skins/content/tinymce-5/content.min.css +1 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.css +66 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.js +2 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.min.css +1 -0
- package/tinymce-assets/skins/content/writer/content.css +0 -6
- package/tinymce-assets/skins/content/writer/content.js +2 -0
- package/tinymce-assets/skins/content/writer/content.min.css +0 -6
- package/tinymce-assets/skins/ui/oxide/content.css +73 -20
- package/tinymce-assets/skins/ui/oxide/content.inline.css +73 -20
- package/tinymce-assets/skins/ui/oxide/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/oxide/content.inline.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide/content.js +2 -0
- package/tinymce-assets/skins/ui/oxide/content.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide/skin.css +1480 -435
- package/tinymce-assets/skins/ui/oxide/skin.js +2 -0
- package/tinymce-assets/skins/ui/oxide/skin.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.css +1 -8
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/content.css +71 -19
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.css +73 -20
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/content.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/content.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/skin.css +1498 -450
- package/tinymce-assets/skins/ui/oxide-dark/skin.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/skin.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.css +1 -8
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.min.css +1 -7
- package/tinymce-assets/skins/ui/tinymce-5/content.css +785 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.css +779 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.css +4185 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.css +30 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.css +766 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.css +779 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.css +4185 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.css +30 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +1 -0
- package/tinymce-assets/themes/silver/theme.js +25226 -28188
- package/tinymce-assets/themes/silver/theme.min.js +2 -7
- package/tinymce-assets/plugins/bbcode/index.js +0 -7
- package/tinymce-assets/plugins/bbcode/plugin.js +0 -99
- package/tinymce-assets/plugins/bbcode/plugin.min.js +0 -9
- package/tinymce-assets/plugins/colorpicker/index.js +0 -7
- package/tinymce-assets/plugins/colorpicker/plugin.js +0 -21
- package/tinymce-assets/plugins/colorpicker/plugin.min.js +0 -9
- package/tinymce-assets/plugins/contextmenu/index.js +0 -7
- package/tinymce-assets/plugins/contextmenu/plugin.js +0 -21
- package/tinymce-assets/plugins/contextmenu/plugin.min.js +0 -9
- package/tinymce-assets/plugins/fullpage/index.js +0 -7
- package/tinymce-assets/plugins/fullpage/plugin.js +0 -544
- package/tinymce-assets/plugins/fullpage/plugin.min.js +0 -9
- package/tinymce-assets/plugins/hr/index.js +0 -7
- package/tinymce-assets/plugins/hr/plugin.js +0 -45
- package/tinymce-assets/plugins/hr/plugin.min.js +0 -9
- package/tinymce-assets/plugins/imagetools/index.js +0 -7
- package/tinymce-assets/plugins/imagetools/plugin.js +0 -1531
- package/tinymce-assets/plugins/imagetools/plugin.min.js +0 -9
- package/tinymce-assets/plugins/legacyoutput/index.js +0 -7
- package/tinymce-assets/plugins/legacyoutput/plugin.js +0 -199
- package/tinymce-assets/plugins/legacyoutput/plugin.min.js +0 -9
- package/tinymce-assets/plugins/noneditable/index.js +0 -7
- package/tinymce-assets/plugins/noneditable/plugin.js +0 -117
- package/tinymce-assets/plugins/noneditable/plugin.min.js +0 -9
- package/tinymce-assets/plugins/paste/index.js +0 -7
- package/tinymce-assets/plugins/paste/plugin.js +0 -1803
- package/tinymce-assets/plugins/paste/plugin.min.js +0 -9
- package/tinymce-assets/plugins/print/index.js +0 -7
- package/tinymce-assets/plugins/print/plugin.js +0 -52
- package/tinymce-assets/plugins/print/plugin.min.js +0 -9
- package/tinymce-assets/plugins/spellchecker/index.js +0 -7
- package/tinymce-assets/plugins/spellchecker/plugin.js +0 -730
- package/tinymce-assets/plugins/spellchecker/plugin.min.js +0 -9
- package/tinymce-assets/plugins/tabfocus/index.js +0 -7
- package/tinymce-assets/plugins/tabfocus/plugin.js +0 -130
- package/tinymce-assets/plugins/tabfocus/plugin.min.js +0 -9
- package/tinymce-assets/plugins/template/index.js +0 -7
- package/tinymce-assets/plugins/template/plugin.js +0 -591
- package/tinymce-assets/plugins/template/plugin.min.js +0 -9
- package/tinymce-assets/plugins/textcolor/index.js +0 -7
- package/tinymce-assets/plugins/textcolor/plugin.js +0 -21
- package/tinymce-assets/plugins/textcolor/plugin.min.js +0 -9
- package/tinymce-assets/plugins/textpattern/index.js +0 -7
- package/tinymce-assets/plugins/textpattern/plugin.js +0 -1374
- package/tinymce-assets/plugins/textpattern/plugin.min.js +0 -9
- package/tinymce-assets/plugins/toc/index.js +0 -7
- package/tinymce-assets/plugins/toc/plugin.js +0 -238
- package/tinymce-assets/plugins/toc/plugin.min.js +0 -9
- package/tinymce-assets/skins/ui/oxide/content.mobile.css +0 -29
- package/tinymce-assets/skins/ui/oxide/content.mobile.min.css +0 -7
- package/tinymce-assets/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
- package/tinymce-assets/skins/ui/oxide/skin.mobile.css +0 -673
- package/tinymce-assets/skins/ui/oxide/skin.mobile.min.css +0 -7
- package/tinymce-assets/skins/ui/oxide-dark/content.mobile.css +0 -29
- package/tinymce-assets/skins/ui/oxide-dark/content.mobile.min.css +0 -7
- package/tinymce-assets/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
- package/tinymce-assets/skins/ui/oxide-dark/skin.mobile.css +0 -673
- package/tinymce-assets/skins/ui/oxide-dark/skin.mobile.min.css +0 -7
- package/tinymce-assets/themes/mobile/index.js +0 -7
- package/tinymce-assets/themes/mobile/theme.js +0 -13130
- package/tinymce-assets/themes/mobile/theme.min.js +0 -9
|
@@ -1,192 +1,205 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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
|
-
|
|
15
|
-
var
|
|
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' &&
|
|
22
|
+
} else if (t === 'object' && Array.isArray(x)) {
|
|
19
23
|
return 'array';
|
|
20
|
-
} else if (t === 'object' && (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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
41
|
+
const noop = () => {
|
|
44
42
|
};
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const compose1 = (fbc, fab) => a => fbc(fab(a));
|
|
44
|
+
const constant = value => {
|
|
45
|
+
return () => {
|
|
47
46
|
return value;
|
|
48
47
|
};
|
|
49
48
|
};
|
|
50
|
-
|
|
51
|
-
return x;
|
|
52
|
-
};
|
|
53
|
-
var tripleEquals = function (a, b) {
|
|
49
|
+
const tripleEquals = (a, b) => {
|
|
54
50
|
return a === b;
|
|
55
51
|
};
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
|
|
52
|
+
function curry(fn, ...initialArgs) {
|
|
53
|
+
return (...restArgs) => {
|
|
54
|
+
const all = initialArgs.concat(restArgs);
|
|
55
|
+
return fn.apply(null, all);
|
|
59
56
|
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
}
|
|
58
|
+
const not = f => t => !f(t);
|
|
59
|
+
const never = constant(false);
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
165
|
-
for (
|
|
166
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
for (
|
|
173
|
-
|
|
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
|
-
|
|
193
|
+
const groupBy = (xs, f) => {
|
|
181
194
|
if (xs.length === 0) {
|
|
182
195
|
return [];
|
|
183
196
|
} else {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
for (
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
204
|
-
each$1(xs,
|
|
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
|
-
|
|
210
|
-
for (
|
|
211
|
-
|
|
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
|
-
|
|
233
|
+
const find = (xs, pred) => {
|
|
221
234
|
return findUntil(xs, pred, never);
|
|
222
235
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
for (
|
|
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
|
-
|
|
234
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
653
|
-
|
|
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
|
-
|
|
271
|
+
const COMMENT = 8;
|
|
272
|
+
const DOCUMENT = 9;
|
|
273
|
+
const DOCUMENT_FRAGMENT = 11;
|
|
274
|
+
const ELEMENT = 1;
|
|
275
|
+
const TEXT = 3;
|
|
660
276
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
-
|
|
667
|
-
|
|
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
|
-
|
|
672
|
-
|
|
673
|
-
|
|
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
|
-
|
|
677
|
-
|
|
678
|
-
|
|
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
|
-
|
|
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
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
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
|
-
|
|
699
|
-
|
|
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
|
-
|
|
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
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
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
|
-
|
|
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
|
-
|
|
341
|
+
const Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
737
342
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
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
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
};
|
|
350
|
+
const resolve = (p, scope) => {
|
|
351
|
+
const parts = p.split('.');
|
|
352
|
+
return path(parts, scope);
|
|
753
353
|
};
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
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
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
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
|
-
|
|
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
|
-
|
|
770
|
-
|
|
375
|
+
const name = element => {
|
|
376
|
+
const r = element.dom.nodeName;
|
|
771
377
|
return r.toLowerCase();
|
|
772
378
|
};
|
|
773
|
-
|
|
774
|
-
|
|
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
|
-
|
|
777
|
-
|
|
778
|
-
|
|
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
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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
|
|
789
|
-
if (
|
|
790
|
-
|
|
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
|
-
|
|
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
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
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
|
-
|
|
816
|
-
|
|
817
|
-
return
|
|
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
|
-
|
|
820
|
-
|
|
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
|
-
|
|
823
|
-
|
|
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
|
-
|
|
827
|
-
|
|
828
|
-
parent$1.each(
|
|
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
|
-
|
|
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
|
-
|
|
837
|
-
each$1(elements,
|
|
494
|
+
const before = (marker, elements) => {
|
|
495
|
+
each$1(elements, x => {
|
|
838
496
|
before$1(marker, x);
|
|
839
497
|
});
|
|
840
498
|
};
|
|
841
|
-
|
|
842
|
-
each$1(elements,
|
|
499
|
+
const append = (parent, elements) => {
|
|
500
|
+
each$1(elements, x => {
|
|
843
501
|
append$1(parent, x);
|
|
844
502
|
});
|
|
845
503
|
};
|
|
846
504
|
|
|
847
|
-
|
|
848
|
-
|
|
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
|
|
855
|
-
|
|
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
|
-
|
|
858
|
-
|
|
557
|
+
const setAll = (element, attrs) => {
|
|
558
|
+
const dom = element.dom;
|
|
559
|
+
each(attrs, (v, k) => {
|
|
560
|
+
rawSet(dom, k, v);
|
|
561
|
+
});
|
|
859
562
|
};
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
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
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
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
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
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
|
-
|
|
915
|
-
|
|
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
|
-
|
|
922
|
-
return dom.isChildOf(elm, dom.getRoot());
|
|
923
|
-
};
|
|
620
|
+
const isChildOfBody = (dom, elm) => dom.isChildOf(elm, dom.getRoot());
|
|
924
621
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
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
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
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 (
|
|
954
|
-
fragment.appendChild(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
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 (!
|
|
980
|
-
|
|
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
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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
|
-
|
|
1003
|
-
for (
|
|
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
|
-
|
|
1014
|
-
|
|
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
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
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
|
-
|
|
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
|
-
|
|
715
|
+
const indentDlItem = item => {
|
|
1034
716
|
if (isDescriptionTerm(item)) {
|
|
1035
717
|
mutate(item, 'dd');
|
|
1036
718
|
}
|
|
1037
719
|
};
|
|
1038
|
-
|
|
720
|
+
const dlIndentation = (editor, indentation, dlItems) => {
|
|
1039
721
|
if (indentation === 'Indent') {
|
|
1040
722
|
each$1(dlItems, indentDlItem);
|
|
1041
723
|
} else {
|
|
1042
|
-
each$1(dlItems,
|
|
1043
|
-
return outdentDlItem(editor, item);
|
|
1044
|
-
});
|
|
724
|
+
each$1(dlItems, item => outdentDlItem(editor, item));
|
|
1045
725
|
}
|
|
1046
726
|
};
|
|
1047
727
|
|
|
1048
|
-
|
|
1049
|
-
if (isTextNode(container)) {
|
|
728
|
+
const getNormalizedPoint = (container, offset) => {
|
|
729
|
+
if (isTextNode$1(container)) {
|
|
1050
730
|
return {
|
|
1051
|
-
container
|
|
1052
|
-
offset
|
|
731
|
+
container,
|
|
732
|
+
offset
|
|
1053
733
|
};
|
|
1054
734
|
}
|
|
1055
|
-
|
|
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
|
|
1074
|
-
offset
|
|
753
|
+
container,
|
|
754
|
+
offset
|
|
1075
755
|
};
|
|
1076
756
|
};
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
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,
|
|
784
|
+
return filter$1(selectedBlocks, elm => {
|
|
1105
785
|
return isListNode(elm) && parentList !== elm;
|
|
1106
786
|
});
|
|
1107
787
|
}
|
|
1108
788
|
};
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
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
|
|
794
|
+
return unique(listItemsElms);
|
|
1115
795
|
};
|
|
1116
|
-
|
|
1117
|
-
|
|
796
|
+
const getSelectedListItems = editor => {
|
|
797
|
+
const selectedBlocks = editor.selection.getSelectedBlocks();
|
|
1118
798
|
return filter$1(findParentListItemsNodes(editor, selectedBlocks), isListItemNode);
|
|
1119
799
|
};
|
|
1120
|
-
|
|
1121
|
-
|
|
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
|
-
|
|
1128
|
-
|
|
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
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
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
|
-
|
|
1137
|
-
|
|
1138
|
-
return
|
|
822
|
+
const getParentLists = editor => {
|
|
823
|
+
const elm = editor.selection.getStart();
|
|
824
|
+
return editor.dom.getParents(elm, 'ol,ul', getClosestListHost(editor, elm));
|
|
1139
825
|
};
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
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
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
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
|
-
|
|
1156
|
-
|
|
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
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
each$1(elements,
|
|
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
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
});
|
|
1173
|
-
};
|
|
866
|
+
const fireListEvent = (editor, action, element) => editor.dispatch('ListMutation', {
|
|
867
|
+
action,
|
|
868
|
+
element
|
|
869
|
+
});
|
|
1174
870
|
|
|
1175
|
-
|
|
1176
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1189
|
-
|
|
887
|
+
const set = (element, property, value) => {
|
|
888
|
+
const dom = element.dom;
|
|
1190
889
|
internalSet(dom, property, value);
|
|
1191
890
|
};
|
|
1192
891
|
|
|
1193
|
-
|
|
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
|
-
|
|
1197
|
-
for (
|
|
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
|
-
|
|
926
|
+
const appendSegments = (head$1, tail) => {
|
|
1202
927
|
lift2(last(head$1), head(tail), joinSegment);
|
|
1203
928
|
};
|
|
1204
|
-
|
|
1205
|
-
|
|
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
|
-
|
|
1213
|
-
|
|
1214
|
-
for (
|
|
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
|
-
|
|
1220
|
-
for (
|
|
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(
|
|
1224
|
-
|
|
1225
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1236
|
-
|
|
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
|
-
|
|
968
|
+
const appendItem = (segment, item) => {
|
|
1242
969
|
append$1(segment.list, item);
|
|
1243
970
|
segment.item = item;
|
|
1244
971
|
};
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
last(newCast).each(
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
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
|
-
|
|
1255
|
-
|
|
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
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
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
|
-
|
|
1266
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1320
|
-
target
|
|
1321
|
-
|
|
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
|
-
|
|
1324
|
-
entry.listAttributes = filter(entry.listAttributes,
|
|
1325
|
-
return key !== 'start';
|
|
1326
|
-
});
|
|
1037
|
+
const cleanListProperties = entry => {
|
|
1038
|
+
entry.listAttributes = filter(entry.listAttributes, (_value, key) => key !== 'start');
|
|
1327
1039
|
};
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
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
|
-
|
|
1341
|
-
each$1(entries,
|
|
1342
|
-
closestSiblingEntry(entries, i).fold(
|
|
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
|
-
},
|
|
1347
|
-
return cloneListProperties(entry, matchingEntry);
|
|
1348
|
-
});
|
|
1052
|
+
}, matchingEntry => cloneListProperties(entry, matchingEntry));
|
|
1349
1053
|
});
|
|
1350
1054
|
return entries;
|
|
1351
1055
|
};
|
|
1352
1056
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1057
|
+
const Cell = initial => {
|
|
1058
|
+
let value = initial;
|
|
1059
|
+
const get = () => {
|
|
1356
1060
|
return value;
|
|
1357
1061
|
};
|
|
1358
|
-
|
|
1062
|
+
const set = v => {
|
|
1359
1063
|
value = v;
|
|
1360
1064
|
};
|
|
1361
1065
|
return {
|
|
1362
|
-
get
|
|
1363
|
-
set
|
|
1066
|
+
get,
|
|
1067
|
+
set
|
|
1364
1068
|
};
|
|
1365
1069
|
};
|
|
1366
1070
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
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
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
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
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
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
|
-
|
|
1414
|
-
|
|
1139
|
+
const indentedComposer = (editor, entries) => {
|
|
1140
|
+
const normalizedEntries = normalizeEntries(entries);
|
|
1415
1141
|
return composeList(editor.contentDocument, normalizedEntries).toArray();
|
|
1416
1142
|
};
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
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
|
-
|
|
1442
|
-
each$1(composedLists,
|
|
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
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
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
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
if (container
|
|
1484
|
-
|
|
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
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
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
|
|
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
|
-
|
|
1524
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1561
|
-
|
|
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
|
-
|
|
1583
|
-
global$2.each(attrs,
|
|
1288
|
+
const setAttribs = (elm, attrs) => {
|
|
1289
|
+
global$2.each(attrs, (value, key) => {
|
|
1584
1290
|
elm.setAttribute(key, value);
|
|
1585
1291
|
});
|
|
1586
1292
|
};
|
|
1587
|
-
|
|
1293
|
+
const updateListAttrs = (dom, el, detail) => {
|
|
1588
1294
|
setAttribs(el, detail['list-attributes']);
|
|
1589
|
-
global$2.each(dom.select('li', el),
|
|
1295
|
+
global$2.each(dom.select('li', el), li => {
|
|
1590
1296
|
setAttribs(li, detail['list-item-attributes']);
|
|
1591
1297
|
});
|
|
1592
1298
|
};
|
|
1593
|
-
|
|
1299
|
+
const updateListWithDetails = (dom, el, detail) => {
|
|
1594
1300
|
updateListStyle(dom, el, detail);
|
|
1595
1301
|
updateListAttrs(dom, el, detail);
|
|
1596
1302
|
};
|
|
1597
|
-
|
|
1598
|
-
global$2.each(styles,
|
|
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
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
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(
|
|
1363
|
+
if (/^(TD|TH)$/.test(parent.nodeName)) {
|
|
1617
1364
|
return container;
|
|
1618
1365
|
}
|
|
1619
|
-
container =
|
|
1366
|
+
container = parent;
|
|
1620
1367
|
}
|
|
1621
1368
|
return container;
|
|
1622
1369
|
};
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
for (
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
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
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
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
|
-
|
|
1684
|
-
|
|
1685
|
-
global$2.each(selectedTextBlocks,
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1719
|
-
return
|
|
1475
|
+
const isValidLists = (list1, list2) => {
|
|
1476
|
+
return isListNode(list1) && list1.nodeName === (list2 === null || list2 === void 0 ? void 0 : list2.nodeName);
|
|
1720
1477
|
};
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
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
|
-
|
|
1483
|
+
const hasSameClasses = (elm1, elm2) => {
|
|
1727
1484
|
return elm1.className === elm2.className;
|
|
1728
1485
|
};
|
|
1729
|
-
|
|
1486
|
+
const shouldMerge = (dom, list1, list2) => {
|
|
1730
1487
|
return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
|
|
1731
1488
|
};
|
|
1732
|
-
|
|
1733
|
-
|
|
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
|
-
|
|
1493
|
+
const liSibling = sibling;
|
|
1494
|
+
while (node = liSibling.firstChild) {
|
|
1737
1495
|
listBlock.appendChild(node);
|
|
1738
1496
|
}
|
|
1739
|
-
dom.remove(
|
|
1497
|
+
dom.remove(liSibling);
|
|
1740
1498
|
}
|
|
1741
1499
|
sibling = listBlock.previousSibling;
|
|
1742
1500
|
if (shouldMerge(dom, listBlock, sibling)) {
|
|
1743
|
-
|
|
1501
|
+
const liSibling = sibling;
|
|
1502
|
+
while (node = liSibling.lastChild) {
|
|
1744
1503
|
listBlock.insertBefore(node, listBlock.firstChild);
|
|
1745
1504
|
}
|
|
1746
|
-
dom.remove(
|
|
1505
|
+
dom.remove(liSibling);
|
|
1747
1506
|
}
|
|
1748
1507
|
};
|
|
1749
|
-
|
|
1508
|
+
const updateList$1 = (editor, list, listName, detail) => {
|
|
1750
1509
|
if (list.nodeName !== listName) {
|
|
1751
|
-
|
|
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
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
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
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
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
|
-
|
|
1554
|
+
const hasListStyleDetail = detail => {
|
|
1774
1555
|
return 'list-style-type' in detail;
|
|
1775
1556
|
};
|
|
1776
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
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
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
if (parentNode.nodeName === 'LI' && parentNode.firstChild === list) {
|
|
1812
|
-
|
|
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
|
-
|
|
1617
|
+
const sibling = parentNode.previousSibling;
|
|
1824
1618
|
if (sibling && sibling.nodeName === 'LI') {
|
|
1825
1619
|
sibling.appendChild(list);
|
|
1826
1620
|
}
|
|
1827
1621
|
}
|
|
1828
1622
|
};
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
global$2.each(lists,
|
|
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
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
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
|
-
|
|
1843
|
-
if (node
|
|
1636
|
+
const nonEmptyBlocks = editor.schema.getNonEmptyElements();
|
|
1637
|
+
if (isElement(node)) {
|
|
1844
1638
|
node = global$6.getNode(node, offset);
|
|
1845
1639
|
}
|
|
1846
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1865
|
-
|
|
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
|
-
|
|
1869
|
-
|
|
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
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
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
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1909
|
-
|
|
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,
|
|
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
|
-
|
|
1918
|
-
|
|
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
|
-
|
|
1923
|
-
|
|
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
|
-
|
|
1724
|
+
const bookmark = createBookmark(rng);
|
|
1928
1725
|
mergeLiElements(dom, fromLi, toLi);
|
|
1929
1726
|
editor.selection.setRng(resolveBookmark(bookmark));
|
|
1930
1727
|
}
|
|
1931
1728
|
};
|
|
1932
|
-
|
|
1933
|
-
|
|
1729
|
+
const mergeBackward = (editor, rng, fromLi, toLi) => {
|
|
1730
|
+
const bookmark = createBookmark(rng);
|
|
1934
1731
|
mergeLiElements(editor.dom, fromLi, toLi);
|
|
1935
|
-
|
|
1732
|
+
const resolvedBookmark = resolveBookmark(bookmark);
|
|
1936
1733
|
editor.selection.setRng(resolvedBookmark);
|
|
1937
1734
|
};
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
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,
|
|
1751
|
+
mergeForward(editor, rng, otherLi, li);
|
|
1954
1752
|
} else {
|
|
1955
1753
|
if (isFirstChild(li)) {
|
|
1956
1754
|
outdentListSelection(editor);
|
|
1957
1755
|
} else {
|
|
1958
|
-
mergeBackward(editor,
|
|
1756
|
+
mergeBackward(editor, rng, li, otherLi);
|
|
1959
1757
|
}
|
|
1960
1758
|
}
|
|
1961
1759
|
});
|
|
1962
1760
|
return true;
|
|
1963
|
-
} else if (!
|
|
1964
|
-
|
|
1965
|
-
|
|
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
|
-
|
|
1975
|
-
|
|
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
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
if (block && dom.isEmpty(block)) {
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
if (
|
|
1990
|
-
|
|
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,
|
|
1993
|
-
editor.selection.select(
|
|
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
|
-
|
|
1823
|
+
const backspaceDeleteCaret = (editor, isForward) => {
|
|
2002
1824
|
return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
|
|
2003
1825
|
};
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
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
|
-
|
|
2018
|
-
|
|
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
|
-
|
|
2021
|
-
editor.on('
|
|
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
|
-
|
|
2035
|
-
|
|
2036
|
-
backspaceDelete
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
};
|
|
2040
|
-
};
|
|
1866
|
+
const get = editor => ({
|
|
1867
|
+
backspaceDelete: isForward => {
|
|
1868
|
+
backspaceDelete(editor, isForward);
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
2041
1871
|
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
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,
|
|
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
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
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,
|
|
2063
|
-
return sum + v;
|
|
2064
|
-
}, 0);
|
|
1893
|
+
return foldl(values, (sum, v) => sum + v, 0);
|
|
2065
1894
|
};
|
|
2066
|
-
|
|
1895
|
+
const composeAlphabeticBase26 = value => {
|
|
2067
1896
|
value--;
|
|
2068
1897
|
if (value < 0) {
|
|
2069
1898
|
return '';
|
|
2070
1899
|
} else {
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
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
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
2127
|
-
|
|
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
|
-
|
|
2138
|
-
|
|
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.
|
|
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:
|
|
2173
|
-
|
|
2174
|
-
parseStartValue(data.start).each(
|
|
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
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
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
|
-
|
|
2192
|
-
editor.addCommand('mceListProps',
|
|
2012
|
+
const registerDialog = editor => {
|
|
2013
|
+
editor.addCommand('mceListProps', () => {
|
|
2193
2014
|
open(editor);
|
|
2194
2015
|
});
|
|
2195
2016
|
};
|
|
2196
|
-
|
|
2197
|
-
editor.on('BeforeExecCommand',
|
|
2198
|
-
|
|
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',
|
|
2026
|
+
editor.addCommand('InsertUnorderedList', (ui, detail) => {
|
|
2206
2027
|
toggleList(editor, 'UL', detail);
|
|
2207
2028
|
});
|
|
2208
|
-
editor.addCommand('InsertOrderedList',
|
|
2029
|
+
editor.addCommand('InsertOrderedList', (ui, detail) => {
|
|
2209
2030
|
toggleList(editor, 'OL', detail);
|
|
2210
2031
|
});
|
|
2211
|
-
editor.addCommand('InsertDefinitionList',
|
|
2032
|
+
editor.addCommand('InsertDefinitionList', (ui, detail) => {
|
|
2212
2033
|
toggleList(editor, 'DL', detail);
|
|
2213
2034
|
});
|
|
2214
|
-
editor.addCommand('RemoveList',
|
|
2035
|
+
editor.addCommand('RemoveList', () => {
|
|
2215
2036
|
flattenListSelection(editor);
|
|
2216
2037
|
});
|
|
2217
2038
|
registerDialog(editor);
|
|
2218
|
-
editor.addCommand('mceListUpdate',
|
|
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
|
|
2229
|
-
|
|
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(
|
|
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
|
-
|
|
2100
|
+
const setup = editor => {
|
|
2241
2101
|
if (shouldIndentOnTab(editor)) {
|
|
2242
2102
|
setupTabKey(editor);
|
|
2243
2103
|
}
|
|
2244
|
-
setup$
|
|
2104
|
+
setup$2(editor);
|
|
2245
2105
|
};
|
|
2246
2106
|
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
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:
|
|
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:
|
|
2269
|
-
return listState(editor, 'UL', api.setActive);
|
|
2270
|
-
}
|
|
2130
|
+
onSetup: setupToggleButtonHandler(editor, 'UL')
|
|
2271
2131
|
});
|
|
2272
2132
|
}
|
|
2273
2133
|
};
|
|
2274
2134
|
|
|
2275
|
-
|
|
2276
|
-
|
|
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:
|
|
2280
|
-
|
|
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:
|
|
2291
|
-
|
|
2148
|
+
update: node => {
|
|
2149
|
+
const parentList = getParentList(editor, node);
|
|
2292
2150
|
return isOlNode(parentList) ? ['listprops'] : [];
|
|
2293
2151
|
}
|
|
2294
2152
|
});
|
|
2295
2153
|
};
|
|
2296
2154
|
|
|
2297
|
-
|
|
2298
|
-
global$7.add('lists',
|
|
2299
|
-
|
|
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
|
+
})();
|