@dangl/angular-material-shared 2.9.0-beta0037 → 2.9.0-beta0040
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/fesm2022/dangl-angular-material-shared-tiny-mce.mjs +29 -35
- package/fesm2022/dangl-angular-material-shared-tiny-mce.mjs.map +1 -1
- package/fesm2022/dangl-angular-material-shared.mjs +36 -51
- package/fesm2022/dangl-angular-material-shared.mjs.map +1 -1
- package/package.json +11 -10
- package/styles/material-theme.scss +1 -1
- package/styles/material-variables.scss +5 -5
- package/tinymce-assets/icons/default/icons.js +46 -9
- package/tinymce-assets/icons/default/icons.min.js +1 -1
- package/tinymce-assets/models/dom/model.js +8198 -7244
- package/tinymce-assets/models/dom/model.min.js +1 -4
- package/tinymce-assets/plugins/accordion/plugin.js +1174 -879
- package/tinymce-assets/plugins/accordion/plugin.min.js +1 -4
- package/tinymce-assets/plugins/advlist/plugin.js +412 -200
- package/tinymce-assets/plugins/advlist/plugin.min.js +1 -4
- package/tinymce-assets/plugins/anchor/plugin.js +189 -166
- package/tinymce-assets/plugins/anchor/plugin.min.js +1 -4
- package/tinymce-assets/plugins/autolink/plugin.js +310 -220
- package/tinymce-assets/plugins/autolink/plugin.min.js +1 -4
- package/tinymce-assets/plugins/autoresize/plugin.js +180 -149
- package/tinymce-assets/plugins/autoresize/plugin.min.js +1 -4
- package/tinymce-assets/plugins/autosave/plugin.js +208 -189
- package/tinymce-assets/plugins/autosave/plugin.min.js +1 -4
- package/tinymce-assets/plugins/charmap/plugin.js +905 -1566
- package/tinymce-assets/plugins/charmap/plugin.min.js +1 -4
- package/tinymce-assets/plugins/code/plugin.js +73 -61
- package/tinymce-assets/plugins/code/plugin.min.js +0 -3
- package/tinymce-assets/plugins/codesample/plugin.js +3593 -2402
- package/tinymce-assets/plugins/codesample/plugin.min.js +8 -3
- package/tinymce-assets/plugins/directionality/plugin.js +545 -304
- package/tinymce-assets/plugins/directionality/plugin.min.js +1 -4
- package/tinymce-assets/plugins/emoticons/js/emojiimages.min.js +0 -2
- package/tinymce-assets/plugins/emoticons/js/emojis.min.js +0 -1
- package/tinymce-assets/plugins/emoticons/plugin.js +702 -488
- package/tinymce-assets/plugins/emoticons/plugin.min.js +1 -4
- package/tinymce-assets/plugins/fullscreen/plugin.js +1409 -1049
- package/tinymce-assets/plugins/fullscreen/plugin.min.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ar.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/bg_BG.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ca.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/cs.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/da.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/de.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/el.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/en.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/es.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/eu.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/fa.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/fi.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/fr_FR.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/he_IL.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/hi.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/hr.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/hu_HU.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/id.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/it.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ja.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/kk.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ko_KR.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ms.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/nb_NO.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/nl.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/pl.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_BR.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_PT.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ro.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ru.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/sk.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/sl_SI.js +5 -2
- package/tinymce-assets/plugins/help/js/i18n/keynav/sv_SE.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/th_TH.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/tr.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/uk.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/vi.js +4 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_CN.js +8 -5
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_TW.js +4 -1
- package/tinymce-assets/plugins/help/plugin.js +739 -809
- package/tinymce-assets/plugins/help/plugin.min.js +1 -4
- package/tinymce-assets/plugins/image/plugin.js +1475 -1291
- package/tinymce-assets/plugins/image/plugin.min.js +1 -4
- package/tinymce-assets/plugins/importcss/plugin.js +328 -269
- package/tinymce-assets/plugins/importcss/plugin.min.js +1 -4
- package/tinymce-assets/plugins/insertdatetime/plugin.js +140 -141
- package/tinymce-assets/plugins/insertdatetime/plugin.min.js +1 -4
- package/tinymce-assets/plugins/link/plugin.js +1419 -1084
- package/tinymce-assets/plugins/link/plugin.min.js +1 -4
- package/tinymce-assets/plugins/lists/plugin.js +2177 -1805
- package/tinymce-assets/plugins/lists/plugin.min.js +1 -4
- package/tinymce-assets/plugins/media/plugin.js +1305 -1047
- package/tinymce-assets/plugins/media/plugin.min.js +1 -4
- package/tinymce-assets/plugins/nonbreaking/plugin.js +93 -88
- package/tinymce-assets/plugins/nonbreaking/plugin.min.js +0 -3
- package/tinymce-assets/plugins/pagebreak/plugin.js +91 -85
- package/tinymce-assets/plugins/pagebreak/plugin.min.js +0 -3
- package/tinymce-assets/plugins/preview/plugin.js +742 -74
- package/tinymce-assets/plugins/preview/plugin.min.js +1 -4
- package/tinymce-assets/plugins/quickbars/plugin.js +582 -375
- package/tinymce-assets/plugins/quickbars/plugin.min.js +1 -4
- package/tinymce-assets/plugins/save/plugin.js +100 -82
- package/tinymce-assets/plugins/save/plugin.min.js +1 -4
- package/tinymce-assets/plugins/searchreplace/plugin.js +1183 -906
- package/tinymce-assets/plugins/searchreplace/plugin.min.js +1 -4
- package/tinymce-assets/plugins/table/plugin.js +3651 -3094
- package/tinymce-assets/plugins/table/plugin.min.js +1 -4
- package/tinymce-assets/plugins/visualblocks/plugin.js +71 -63
- package/tinymce-assets/plugins/visualblocks/plugin.min.js +1 -4
- package/tinymce-assets/plugins/visualchars/plugin.js +685 -436
- package/tinymce-assets/plugins/visualchars/plugin.min.js +1 -4
- package/tinymce-assets/plugins/wordcount/plugin.js +382 -307
- package/tinymce-assets/plugins/wordcount/plugin.min.js +1 -4
- package/tinymce-assets/skins/content/dark/content.css +9 -0
- package/tinymce-assets/skins/content/dark/content.js +10 -2
- package/tinymce-assets/skins/content/dark/content.min.css +9 -0
- package/tinymce-assets/skins/content/default/content.css +9 -0
- package/tinymce-assets/skins/content/default/content.js +10 -2
- package/tinymce-assets/skins/content/default/content.min.css +9 -0
- package/tinymce-assets/skins/content/document/content.css +9 -0
- package/tinymce-assets/skins/content/document/content.js +10 -2
- package/tinymce-assets/skins/content/document/content.min.css +9 -0
- package/tinymce-assets/skins/content/tinymce-5/content.css +9 -0
- package/tinymce-assets/skins/content/tinymce-5/content.js +10 -2
- package/tinymce-assets/skins/content/tinymce-5/content.min.css +9 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.css +9 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.js +10 -2
- package/tinymce-assets/skins/content/tinymce-5-dark/content.min.css +9 -0
- package/tinymce-assets/skins/content/writer/content.css +9 -0
- package/tinymce-assets/skins/content/writer/content.js +10 -2
- package/tinymce-assets/skins/content/writer/content.min.css +9 -0
- package/tinymce-assets/skins/ui/oxide/content.css +157 -49
- package/tinymce-assets/skins/ui/oxide/content.inline.css +157 -49
- package/tinymce-assets/skins/ui/oxide/content.inline.js +10 -2
- package/tinymce-assets/skins/ui/oxide/content.inline.min.css +10 -1
- package/tinymce-assets/skins/ui/oxide/content.js +10 -2
- package/tinymce-assets/skins/ui/oxide/content.min.css +10 -1
- package/tinymce-assets/skins/ui/oxide/skin.css +1592 -214
- package/tinymce-assets/skins/ui/oxide/skin.js +1 -2
- package/tinymce-assets/skins/ui/oxide/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.js +1 -2
- package/tinymce-assets/skins/ui/oxide-dark/content.css +157 -42
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.css +157 -49
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.js +10 -2
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.min.css +10 -1
- package/tinymce-assets/skins/ui/oxide-dark/content.js +10 -2
- package/tinymce-assets/skins/ui/oxide-dark/content.min.css +10 -1
- package/tinymce-assets/skins/ui/oxide-dark/skin.css +1595 -217
- package/tinymce-assets/skins/ui/oxide-dark/skin.js +1 -2
- package/tinymce-assets/skins/ui/oxide-dark/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.js +1 -2
- package/tinymce-assets/skins/ui/tinymce-5/content.css +157 -49
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.css +157 -49
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.js +10 -2
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.min.css +10 -1
- package/tinymce-assets/skins/ui/tinymce-5/content.js +10 -2
- package/tinymce-assets/skins/ui/tinymce-5/content.min.css +10 -1
- package/tinymce-assets/skins/ui/tinymce-5/skin.css +1606 -203
- package/tinymce-assets/skins/ui/tinymce-5/skin.js +1 -2
- package/tinymce-assets/skins/ui/tinymce-5/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.js +1 -2
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.css +157 -42
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.css +157 -49
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.js +10 -2
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.min.css +10 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.js +10 -2
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.min.css +10 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.css +1607 -204
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.js +1 -2
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.js +1 -2
- package/tinymce-assets/themes/silver/theme.js +32786 -28738
- package/tinymce-assets/themes/silver/theme.min.js +1 -4
- package/types/dangl-angular-material-shared-tiny-mce.d.ts +12 -13
- package/types/dangl-angular-material-shared.d.ts +26 -26
- package/tinymce-assets/plugins/template/index.js +0 -7
- package/tinymce-assets/plugins/template/plugin.js +0 -567
- package/tinymce-assets/plugins/template/plugin.min.js +0 -4
|
@@ -1,560 +1,809 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TinyMCE version
|
|
2
|
+
* TinyMCE version 7.9.3 (2026-05-19)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function () {
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
set
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
23
|
-
|
|
24
|
-
const get$2 = toggleState => {
|
|
25
|
-
const isEnabled = () => {
|
|
26
|
-
return toggleState.get();
|
|
27
|
-
};
|
|
28
|
-
return { isEnabled };
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-wrapper-object-types */
|
|
9
|
+
const hasProto = (v, constructor, predicate) => {
|
|
10
|
+
var _a;
|
|
11
|
+
if (predicate(v, constructor.prototype)) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
// String-based fallback time
|
|
16
|
+
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
17
|
+
}
|
|
29
18
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
const typeOf = (x) => {
|
|
20
|
+
const t = typeof x;
|
|
21
|
+
if (x === null) {
|
|
22
|
+
return 'null';
|
|
23
|
+
}
|
|
24
|
+
else if (t === 'object' && Array.isArray(x)) {
|
|
25
|
+
return 'array';
|
|
26
|
+
}
|
|
27
|
+
else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
28
|
+
return 'string';
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return t;
|
|
32
|
+
}
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (predicate(v, constructor.prototype)) {
|
|
38
|
-
return true;
|
|
39
|
-
} else {
|
|
40
|
-
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const typeOf = x => {
|
|
44
|
-
const t = typeof x;
|
|
45
|
-
if (x === null) {
|
|
46
|
-
return 'null';
|
|
47
|
-
} else if (t === 'object' && Array.isArray(x)) {
|
|
48
|
-
return 'array';
|
|
49
|
-
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
50
|
-
return 'string';
|
|
51
|
-
} else {
|
|
52
|
-
return t;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const isType$1 = type => value => typeOf(value) === type;
|
|
56
|
-
const isSimpleType = type => value => typeof value === type;
|
|
57
|
-
const eq = t => a => t === a;
|
|
34
|
+
const isType$1 = (type) => (value) => typeOf(value) === type;
|
|
35
|
+
const isSimpleType = (type) => (value) => typeof value === type;
|
|
36
|
+
const eq = (t) => (a) => t === a;
|
|
58
37
|
const isString = isType$1('string');
|
|
59
38
|
const isObject = isType$1('object');
|
|
60
39
|
const isNull = eq(null);
|
|
61
40
|
const isBoolean = isSimpleType('boolean');
|
|
62
|
-
const isNullable = a => a === null || a === undefined;
|
|
63
|
-
const isNonNullable = a => !isNullable(a);
|
|
41
|
+
const isNullable = (a) => a === null || a === undefined;
|
|
42
|
+
const isNonNullable = (a) => !isNullable(a);
|
|
43
|
+
const isFunction = isSimpleType('function');
|
|
64
44
|
const isNumber = isSimpleType('number');
|
|
65
45
|
|
|
46
|
+
/**
|
|
47
|
+
* The `Optional` type represents a value (of any type) that potentially does
|
|
48
|
+
* not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
|
|
49
|
+
* value does exist) or a `None` (in which case the value does not exist). This
|
|
50
|
+
* module defines a whole lot of FP-inspired utility functions for dealing with
|
|
51
|
+
* `Optional` objects.
|
|
52
|
+
*
|
|
53
|
+
* Comparison with null or undefined:
|
|
54
|
+
* - We don't get fancy null coalescing operators with `Optional`
|
|
55
|
+
* - We do get fancy helper functions with `Optional`
|
|
56
|
+
* - `Optional` support nesting, and allow for the type to still be nullable (or
|
|
57
|
+
* another `Optional`)
|
|
58
|
+
* - There is no option to turn off strict-optional-checks like there is for
|
|
59
|
+
* strict-null-checks
|
|
60
|
+
*/
|
|
66
61
|
class Optional {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
62
|
+
// The internal representation has a `tag` and a `value`, but both are
|
|
63
|
+
// private: able to be console.logged, but not able to be accessed by code
|
|
64
|
+
constructor(tag, value) {
|
|
65
|
+
this.tag = tag;
|
|
66
|
+
this.value = value;
|
|
67
|
+
}
|
|
68
|
+
// --- Identities ---
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new `Optional<T>` that **does** contain a value.
|
|
71
|
+
*/
|
|
72
|
+
static some(value) {
|
|
73
|
+
return new Optional(true, value);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create a new `Optional<T>` that **does not** contain a value. `T` can be
|
|
77
|
+
* any type because we don't actually have a `T`.
|
|
78
|
+
*/
|
|
79
|
+
static none() {
|
|
80
|
+
return Optional.singletonNone;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Perform a transform on an `Optional` type. Regardless of whether this
|
|
84
|
+
* `Optional` contains a value or not, `fold` will return a value of type `U`.
|
|
85
|
+
* If this `Optional` does not contain a value, the `U` will be created by
|
|
86
|
+
* calling `onNone`. If this `Optional` does contain a value, the `U` will be
|
|
87
|
+
* created by calling `onSome`.
|
|
88
|
+
*
|
|
89
|
+
* For the FP enthusiasts in the room, this function:
|
|
90
|
+
* 1. Could be used to implement all of the functions below
|
|
91
|
+
* 2. Forms a catamorphism
|
|
92
|
+
*/
|
|
93
|
+
fold(onNone, onSome) {
|
|
94
|
+
if (this.tag) {
|
|
95
|
+
return onSome(this.value);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return onNone();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Determine if this `Optional` object contains a value.
|
|
103
|
+
*/
|
|
104
|
+
isSome() {
|
|
105
|
+
return this.tag;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Determine if this `Optional` object **does not** contain a value.
|
|
109
|
+
*/
|
|
110
|
+
isNone() {
|
|
111
|
+
return !this.tag;
|
|
112
|
+
}
|
|
113
|
+
// --- Functor (name stolen from Haskell / maths) ---
|
|
114
|
+
/**
|
|
115
|
+
* Perform a transform on an `Optional` object, **if** there is a value. If
|
|
116
|
+
* you provide a function to turn a T into a U, this is the function you use
|
|
117
|
+
* to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
|
|
118
|
+
* a value then the output will also contain a value (that value being the
|
|
119
|
+
* output of `mapper(this.value)`), and if this **does not** contain a value
|
|
120
|
+
* then neither will the output.
|
|
121
|
+
*/
|
|
122
|
+
map(mapper) {
|
|
123
|
+
if (this.tag) {
|
|
124
|
+
return Optional.some(mapper(this.value));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
return Optional.none();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// --- Monad (name stolen from Haskell / maths) ---
|
|
131
|
+
/**
|
|
132
|
+
* Perform a transform on an `Optional` object, **if** there is a value.
|
|
133
|
+
* Unlike `map`, here the transform itself also returns an `Optional`.
|
|
134
|
+
*/
|
|
135
|
+
bind(binder) {
|
|
136
|
+
if (this.tag) {
|
|
137
|
+
return binder(this.value);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
return Optional.none();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// --- Traversable (name stolen from Haskell / maths) ---
|
|
144
|
+
/**
|
|
145
|
+
* For a given predicate, this function finds out if there **exists** a value
|
|
146
|
+
* inside this `Optional` object that meets the predicate. In practice, this
|
|
147
|
+
* means that for `Optional`s that do not contain a value it returns false (as
|
|
148
|
+
* no predicate-meeting value exists).
|
|
149
|
+
*/
|
|
150
|
+
exists(predicate) {
|
|
151
|
+
return this.tag && predicate(this.value);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* For a given predicate, this function finds out if **all** the values inside
|
|
155
|
+
* this `Optional` object meet the predicate. In practice, this means that
|
|
156
|
+
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
157
|
+
* objects do meet the predicate).
|
|
158
|
+
*/
|
|
159
|
+
forall(predicate) {
|
|
160
|
+
return !this.tag || predicate(this.value);
|
|
161
|
+
}
|
|
162
|
+
filter(predicate) {
|
|
163
|
+
if (!this.tag || predicate(this.value)) {
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
return Optional.none();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// --- Getters ---
|
|
171
|
+
/**
|
|
172
|
+
* Get the value out of the inside of the `Optional` object, using a default
|
|
173
|
+
* `replacement` value if the provided `Optional` object does not contain a
|
|
174
|
+
* value.
|
|
175
|
+
*/
|
|
176
|
+
getOr(replacement) {
|
|
177
|
+
return this.tag ? this.value : replacement;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get the value out of the inside of the `Optional` object, using a default
|
|
181
|
+
* `replacement` value if the provided `Optional` object does not contain a
|
|
182
|
+
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
183
|
+
* `Optional` - meaning that this method will always return an `Optional`.
|
|
184
|
+
*/
|
|
185
|
+
or(replacement) {
|
|
186
|
+
return this.tag ? this : replacement;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get the value out of the inside of the `Optional` object, using a default
|
|
190
|
+
* `replacement` value if the provided `Optional` object does not contain a
|
|
191
|
+
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
192
|
+
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
193
|
+
* pass a function which (if called) will **return** the `value` you want to
|
|
194
|
+
* use.
|
|
195
|
+
*/
|
|
196
|
+
getOrThunk(thunk) {
|
|
197
|
+
return this.tag ? this.value : thunk();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get the value out of the inside of the `Optional` object, using a default
|
|
201
|
+
* `replacement` value if the provided Optional object does not contain a
|
|
202
|
+
* value.
|
|
203
|
+
*
|
|
204
|
+
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
205
|
+
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
206
|
+
* (if called) will **return** the `value` you want to use.
|
|
207
|
+
*
|
|
208
|
+
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
209
|
+
* `Optional`, meaning that this method will always return an `Optional`.
|
|
210
|
+
*/
|
|
211
|
+
orThunk(thunk) {
|
|
212
|
+
return this.tag ? this : thunk();
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get the value out of the inside of the `Optional` object, throwing an
|
|
216
|
+
* exception if the provided `Optional` object does not contain a value.
|
|
217
|
+
*
|
|
218
|
+
* WARNING:
|
|
219
|
+
* You should only be using this function if you know that the `Optional`
|
|
220
|
+
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
221
|
+
* code, which is bad).
|
|
222
|
+
*
|
|
223
|
+
* In tests this is more acceptable.
|
|
224
|
+
*
|
|
225
|
+
* Prefer other methods to this, such as `.each`.
|
|
226
|
+
*/
|
|
227
|
+
getOrDie(message) {
|
|
228
|
+
if (!this.tag) {
|
|
229
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return this.value;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// --- Interop with null and undefined ---
|
|
236
|
+
/**
|
|
237
|
+
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
238
|
+
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
239
|
+
* to `Some`.
|
|
240
|
+
*/
|
|
241
|
+
static from(value) {
|
|
242
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Converts an `Optional` to a nullable type, by getting the value if it
|
|
246
|
+
* exists, or returning `null` if it does not.
|
|
247
|
+
*/
|
|
248
|
+
getOrNull() {
|
|
249
|
+
return this.tag ? this.value : null;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Converts an `Optional` to an undefined-able type, by getting the value if
|
|
253
|
+
* it exists, or returning `undefined` if it does not.
|
|
254
|
+
*/
|
|
255
|
+
getOrUndefined() {
|
|
256
|
+
return this.value;
|
|
257
|
+
}
|
|
258
|
+
// --- Utilities ---
|
|
259
|
+
/**
|
|
260
|
+
* If the `Optional` contains a value, perform an action on that value.
|
|
261
|
+
* Unlike the rest of the methods on this type, `.each` has side-effects. If
|
|
262
|
+
* you want to transform an `Optional<T>` **into** something, then this is not
|
|
263
|
+
* the method for you. If you want to use an `Optional<T>` to **do**
|
|
264
|
+
* something, then this is the method for you - provided you're okay with not
|
|
265
|
+
* doing anything in the case where the `Optional` doesn't have a value inside
|
|
266
|
+
* it. If you're not sure whether your use-case fits into transforming
|
|
267
|
+
* **into** something or **doing** something, check whether it has a return
|
|
268
|
+
* value. If it does, you should be performing a transform.
|
|
269
|
+
*/
|
|
270
|
+
each(worker) {
|
|
271
|
+
if (this.tag) {
|
|
272
|
+
worker(this.value);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Turn the `Optional` object into an array that contains all of the values
|
|
277
|
+
* stored inside the `Optional`. In practice, this means the output will have
|
|
278
|
+
* either 0 or 1 elements.
|
|
279
|
+
*/
|
|
280
|
+
toArray() {
|
|
281
|
+
return this.tag ? [this.value] : [];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Turn the `Optional` object into a string for debugging or printing. Not
|
|
285
|
+
* recommended for production code, but good for debugging. Also note that
|
|
286
|
+
* these days an `Optional` object can be logged to the console directly, and
|
|
287
|
+
* its inner value (if it exists) will be visible.
|
|
288
|
+
*/
|
|
289
|
+
toString() {
|
|
290
|
+
return this.tag ? `some(${this.value})` : 'none()';
|
|
291
|
+
}
|
|
156
292
|
}
|
|
293
|
+
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
294
|
+
// reuse the same object
|
|
157
295
|
Optional.singletonNone = new Optional(false);
|
|
158
296
|
|
|
297
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
298
|
+
const nativeSlice = Array.prototype.slice;
|
|
159
299
|
const map = (xs, f) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
300
|
+
// pre-allocating array size when it's guaranteed to be known
|
|
301
|
+
// http://jsperf.com/push-allocated-vs-dynamic/22
|
|
302
|
+
const len = xs.length;
|
|
303
|
+
const r = new Array(len);
|
|
304
|
+
for (let i = 0; i < len; i++) {
|
|
305
|
+
const x = xs[i];
|
|
306
|
+
r[i] = f(x, i);
|
|
307
|
+
}
|
|
308
|
+
return r;
|
|
167
309
|
};
|
|
310
|
+
// Unwound implementing other functions in terms of each.
|
|
311
|
+
// The code size is roughly the same, and it should allow for better optimisation.
|
|
312
|
+
// const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
|
|
168
313
|
const each$1 = (xs, f) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
314
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
315
|
+
const x = xs[i];
|
|
316
|
+
f(x, i);
|
|
317
|
+
}
|
|
173
318
|
};
|
|
174
319
|
const filter = (xs, pred) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
320
|
+
const r = [];
|
|
321
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
322
|
+
const x = xs[i];
|
|
323
|
+
if (pred(x, i)) {
|
|
324
|
+
r.push(x);
|
|
325
|
+
}
|
|
180
326
|
}
|
|
181
|
-
|
|
182
|
-
return r;
|
|
327
|
+
return r;
|
|
183
328
|
};
|
|
329
|
+
isFunction(Array.from) ? Array.from : (x) => nativeSlice.call(x);
|
|
184
330
|
|
|
331
|
+
// There are many variations of Object iteration that are faster than the 'for-in' style:
|
|
332
|
+
// http://jsperf.com/object-keys-iteration/107
|
|
333
|
+
//
|
|
334
|
+
// Use the native keys if it is available (IE9+), otherwise fall back to manually filtering
|
|
185
335
|
const keys = Object.keys;
|
|
186
336
|
const each = (obj, f) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
337
|
+
const props = keys(obj);
|
|
338
|
+
for (let k = 0, len = props.length; k < len; k++) {
|
|
339
|
+
const i = props[k];
|
|
340
|
+
const x = obj[i];
|
|
341
|
+
f(x, i);
|
|
342
|
+
}
|
|
193
343
|
};
|
|
194
344
|
|
|
345
|
+
const Cell = (initial) => {
|
|
346
|
+
let value = initial;
|
|
347
|
+
const get = () => {
|
|
348
|
+
return value;
|
|
349
|
+
};
|
|
350
|
+
const set = (v) => {
|
|
351
|
+
value = v;
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
get,
|
|
355
|
+
set
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// Use window object as the global if it's available since CSP will block script evals
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
195
361
|
const Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
196
362
|
|
|
363
|
+
/** path :: ([String], JsObj?) -> JsObj */
|
|
197
364
|
const path = (parts, scope) => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
365
|
+
let o = scope !== undefined && scope !== null ? scope : Global;
|
|
366
|
+
for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
|
|
367
|
+
o = o[parts[i]];
|
|
368
|
+
}
|
|
369
|
+
return o;
|
|
203
370
|
};
|
|
371
|
+
/** resolve :: (String, JsObj?) -> JsObj */
|
|
204
372
|
const resolve = (p, scope) => {
|
|
205
|
-
|
|
206
|
-
|
|
373
|
+
const parts = p.split('.');
|
|
374
|
+
return path(parts, scope);
|
|
207
375
|
};
|
|
208
376
|
|
|
209
|
-
|
|
210
|
-
|
|
377
|
+
// Run a function fn after rate ms. If another invocation occurs
|
|
378
|
+
// during the time it is waiting, ignore it completely.
|
|
379
|
+
const first = (fn, rate) => {
|
|
380
|
+
let timer = null;
|
|
381
|
+
const cancel = () => {
|
|
382
|
+
if (!isNull(timer)) {
|
|
383
|
+
clearTimeout(timer);
|
|
384
|
+
timer = null;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const throttle = (...args) => {
|
|
388
|
+
if (isNull(timer)) {
|
|
389
|
+
timer = setTimeout(() => {
|
|
390
|
+
timer = null;
|
|
391
|
+
fn.apply(null, args);
|
|
392
|
+
}, rate);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
return {
|
|
396
|
+
cancel,
|
|
397
|
+
throttle
|
|
398
|
+
};
|
|
211
399
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
400
|
+
|
|
401
|
+
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
402
|
+
|
|
403
|
+
const get$2 = (toggleState) => {
|
|
404
|
+
const isEnabled = () => {
|
|
405
|
+
return toggleState.get();
|
|
406
|
+
};
|
|
407
|
+
return {
|
|
408
|
+
isEnabled
|
|
409
|
+
};
|
|
218
410
|
};
|
|
219
411
|
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
412
|
+
const fireVisualChars = (editor, state) => {
|
|
413
|
+
return editor.dispatch('VisualChars', { state });
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
const fromHtml = (html, scope) => {
|
|
417
|
+
const doc = scope || document;
|
|
418
|
+
const div = doc.createElement('div');
|
|
419
|
+
div.innerHTML = html;
|
|
420
|
+
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
421
|
+
const message = 'HTML does not have a single root node';
|
|
422
|
+
// eslint-disable-next-line no-console
|
|
423
|
+
console.error(message, html);
|
|
424
|
+
throw new Error(message);
|
|
425
|
+
}
|
|
426
|
+
return fromDom(div.childNodes[0]);
|
|
427
|
+
};
|
|
428
|
+
const fromTag = (tag, scope) => {
|
|
429
|
+
const doc = scope || document;
|
|
430
|
+
const node = doc.createElement(tag);
|
|
431
|
+
return fromDom(node);
|
|
432
|
+
};
|
|
433
|
+
const fromText = (text, scope) => {
|
|
434
|
+
const doc = scope || document;
|
|
435
|
+
const node = doc.createTextNode(text);
|
|
436
|
+
return fromDom(node);
|
|
437
|
+
};
|
|
438
|
+
const fromDom = (node) => {
|
|
439
|
+
// TODO: Consider removing this check, but left atm for safety
|
|
440
|
+
if (node === null || node === undefined) {
|
|
441
|
+
throw new Error('Node cannot be null or undefined');
|
|
442
|
+
}
|
|
443
|
+
return {
|
|
444
|
+
dom: node
|
|
445
|
+
};
|
|
223
446
|
};
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
447
|
+
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
448
|
+
// tslint:disable-next-line:variable-name
|
|
449
|
+
const SugarElement = {
|
|
450
|
+
fromHtml,
|
|
451
|
+
fromTag,
|
|
452
|
+
fromText,
|
|
453
|
+
fromDom,
|
|
454
|
+
fromPoint
|
|
227
455
|
};
|
|
228
456
|
|
|
229
457
|
const ELEMENT = 1;
|
|
230
458
|
const TEXT = 3;
|
|
231
459
|
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
460
|
+
const unsafe = (name, scope) => {
|
|
461
|
+
return resolve(name, scope);
|
|
462
|
+
};
|
|
463
|
+
const getOrDie = (name, scope) => {
|
|
464
|
+
const actual = unsafe(name, scope);
|
|
465
|
+
if (actual === undefined || actual === null) {
|
|
466
|
+
throw new Error(name + ' not available on this browser');
|
|
467
|
+
}
|
|
468
|
+
return actual;
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
472
|
+
/*
|
|
473
|
+
* IE9 and above
|
|
474
|
+
*
|
|
475
|
+
* MDN no use on this one, but here's the link anyway:
|
|
476
|
+
* https://developer.mozilla.org/en/docs/Web/API/HTMLElement
|
|
477
|
+
*/
|
|
478
|
+
const sandHTMLElement = (scope) => {
|
|
479
|
+
return getOrDie('HTMLElement', scope);
|
|
480
|
+
};
|
|
481
|
+
const isPrototypeOf = (x) => {
|
|
482
|
+
// use Resolve to get the window object for x and just return undefined if it can't find it.
|
|
483
|
+
// undefined scope later triggers using the global window.
|
|
484
|
+
const scope = resolve('ownerDocument.defaultView', x);
|
|
485
|
+
// TINY-7374: We can't rely on looking at the owner window HTMLElement as the element may have
|
|
486
|
+
// been constructed in a different window and then appended to the current window document.
|
|
487
|
+
return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const type = (element) => element.dom.nodeType;
|
|
491
|
+
const value = (element) => element.dom.nodeValue;
|
|
492
|
+
const isType = (t) => (element) => type(element) === t;
|
|
493
|
+
const isHTMLElement = (element) => isElement(element) && isPrototypeOf(element.dom);
|
|
236
494
|
const isElement = isType(ELEMENT);
|
|
237
495
|
const isText = isType(TEXT);
|
|
238
496
|
|
|
239
497
|
const rawSet = (dom, key, value) => {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
498
|
+
/*
|
|
499
|
+
* JQuery coerced everything to a string, and silently did nothing on text node/null/undefined.
|
|
500
|
+
*
|
|
501
|
+
* We fail on those invalid cases, only allowing numbers and booleans.
|
|
502
|
+
*/
|
|
503
|
+
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
504
|
+
dom.setAttribute(key, value + '');
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
// eslint-disable-next-line no-console
|
|
508
|
+
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
509
|
+
throw new Error('Attribute value was not simple');
|
|
510
|
+
}
|
|
246
511
|
};
|
|
247
512
|
const set = (element, key, value) => {
|
|
248
|
-
|
|
513
|
+
rawSet(element.dom, key, value);
|
|
249
514
|
};
|
|
250
515
|
const get$1 = (element, key) => {
|
|
251
|
-
|
|
252
|
-
|
|
516
|
+
const v = element.dom.getAttribute(key);
|
|
517
|
+
// undefined is the more appropriate value for JS, and this matches JQuery
|
|
518
|
+
return v === null ? undefined : v;
|
|
253
519
|
};
|
|
254
520
|
const remove$3 = (element, key) => {
|
|
255
|
-
|
|
521
|
+
element.dom.removeAttribute(key);
|
|
256
522
|
};
|
|
257
523
|
|
|
524
|
+
// Methods for handling attributes that contain a list of values <div foo="alpha beta theta">
|
|
258
525
|
const read = (element, attr) => {
|
|
259
|
-
|
|
260
|
-
|
|
526
|
+
const value = get$1(element, attr);
|
|
527
|
+
return value === undefined || value === '' ? [] : value.split(' ');
|
|
261
528
|
};
|
|
262
529
|
const add$2 = (element, attr, id) => {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
530
|
+
const old = read(element, attr);
|
|
531
|
+
const nu = old.concat([id]);
|
|
532
|
+
set(element, attr, nu.join(' '));
|
|
533
|
+
return true;
|
|
267
534
|
};
|
|
268
535
|
const remove$2 = (element, attr, id) => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
536
|
+
const nu = filter(read(element, attr), (v) => v !== id);
|
|
537
|
+
if (nu.length > 0) {
|
|
538
|
+
set(element, attr, nu.join(' '));
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
remove$3(element, attr);
|
|
542
|
+
}
|
|
543
|
+
return false;
|
|
276
544
|
};
|
|
277
545
|
|
|
278
|
-
|
|
279
|
-
const
|
|
546
|
+
// IE11 Can return undefined for a classList on elements such as math, so we make sure it's not undefined before attempting to use it.
|
|
547
|
+
const supports = (element) => element.dom.classList !== undefined;
|
|
548
|
+
const get = (element) => read(element, 'class');
|
|
280
549
|
const add$1 = (element, clazz) => add$2(element, 'class', clazz);
|
|
281
550
|
const remove$1 = (element, clazz) => remove$2(element, 'class', clazz);
|
|
282
551
|
|
|
552
|
+
/*
|
|
553
|
+
* ClassList is IE10 minimum:
|
|
554
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Element.classList
|
|
555
|
+
*
|
|
556
|
+
* Note that IE doesn't support the second argument to toggle (at all).
|
|
557
|
+
* If it did, the toggler could be better.
|
|
558
|
+
*/
|
|
283
559
|
const add = (element, clazz) => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
560
|
+
if (supports(element)) {
|
|
561
|
+
element.dom.classList.add(clazz);
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
add$1(element, clazz);
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
const cleanClass = (element) => {
|
|
568
|
+
const classList = supports(element) ? element.dom.classList : get(element);
|
|
569
|
+
// classList is a "live list", so this is up to date already
|
|
570
|
+
if (classList.length === 0) {
|
|
571
|
+
// No more classes left, remove the class attribute as well
|
|
572
|
+
remove$3(element, 'class');
|
|
573
|
+
}
|
|
295
574
|
};
|
|
296
575
|
const remove = (element, clazz) => {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
576
|
+
if (supports(element)) {
|
|
577
|
+
const classList = element.dom.classList;
|
|
578
|
+
classList.remove(clazz);
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
remove$1(element, clazz);
|
|
582
|
+
}
|
|
583
|
+
cleanClass(element);
|
|
304
584
|
};
|
|
305
585
|
|
|
306
|
-
const
|
|
307
|
-
const doc = scope || document;
|
|
308
|
-
const div = doc.createElement('div');
|
|
309
|
-
div.innerHTML = html;
|
|
310
|
-
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
311
|
-
const message = 'HTML does not have a single root node';
|
|
312
|
-
console.error(message, html);
|
|
313
|
-
throw new Error(message);
|
|
314
|
-
}
|
|
315
|
-
return fromDom(div.childNodes[0]);
|
|
316
|
-
};
|
|
317
|
-
const fromTag = (tag, scope) => {
|
|
318
|
-
const doc = scope || document;
|
|
319
|
-
const node = doc.createElement(tag);
|
|
320
|
-
return fromDom(node);
|
|
321
|
-
};
|
|
322
|
-
const fromText = (text, scope) => {
|
|
323
|
-
const doc = scope || document;
|
|
324
|
-
const node = doc.createTextNode(text);
|
|
325
|
-
return fromDom(node);
|
|
326
|
-
};
|
|
327
|
-
const fromDom = node => {
|
|
328
|
-
if (node === null || node === undefined) {
|
|
329
|
-
throw new Error('Node cannot be null or undefined');
|
|
330
|
-
}
|
|
331
|
-
return { dom: node };
|
|
332
|
-
};
|
|
333
|
-
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
334
|
-
const SugarElement = {
|
|
335
|
-
fromHtml,
|
|
336
|
-
fromTag,
|
|
337
|
-
fromText,
|
|
338
|
-
fromDom,
|
|
339
|
-
fromPoint
|
|
340
|
-
};
|
|
586
|
+
const getRaw = (element) => element.dom.contentEditable;
|
|
341
587
|
|
|
342
588
|
const charMap = {
|
|
343
|
-
|
|
344
|
-
|
|
589
|
+
'\u00a0': 'nbsp',
|
|
590
|
+
'\u00ad': 'shy'
|
|
345
591
|
};
|
|
346
592
|
const charMapToRegExp = (charMap, global) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
};
|
|
353
|
-
const charMapToSelector = charMap => {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
593
|
+
let regExp = '';
|
|
594
|
+
each(charMap, (_value, key) => {
|
|
595
|
+
regExp += key;
|
|
596
|
+
});
|
|
597
|
+
return new RegExp('[' + regExp + ']', global ? 'g' : '');
|
|
598
|
+
};
|
|
599
|
+
const charMapToSelector = (charMap) => {
|
|
600
|
+
let selector = '';
|
|
601
|
+
each(charMap, (value) => {
|
|
602
|
+
if (selector) {
|
|
603
|
+
selector += ',';
|
|
604
|
+
}
|
|
605
|
+
selector += 'span.mce-' + value;
|
|
606
|
+
});
|
|
607
|
+
return selector;
|
|
362
608
|
};
|
|
363
609
|
const regExp = charMapToRegExp(charMap);
|
|
364
610
|
const regExpGlobal = charMapToRegExp(charMap, true);
|
|
365
611
|
const selector = charMapToSelector(charMap);
|
|
366
612
|
const nbspClass = 'mce-nbsp';
|
|
367
613
|
|
|
368
|
-
const
|
|
614
|
+
const wrapCharWithSpan = (value) => '<span data-mce-bogus="1" class="mce-' + charMap[value] + '">' + value + '</span>';
|
|
369
615
|
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
616
|
+
const isWrappedNbsp = (node) => node.nodeName.toLowerCase() === 'span' && node.classList.contains('mce-nbsp-wrap');
|
|
617
|
+
const isMatch = (n) => {
|
|
618
|
+
const value$1 = value(n);
|
|
619
|
+
return isText(n) &&
|
|
620
|
+
isString(value$1) &&
|
|
621
|
+
regExp.test(value$1);
|
|
376
622
|
};
|
|
377
|
-
const isContentEditableFalse = node => isHTMLElement(node) && getRaw(node) === 'false';
|
|
623
|
+
const isContentEditableFalse = (node) => isHTMLElement(node) && getRaw(node) === 'false';
|
|
378
624
|
const isChildEditable = (node, currentState) => {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
625
|
+
if (isHTMLElement(node) && !isWrappedNbsp(node.dom)) {
|
|
626
|
+
const value = getRaw(node);
|
|
627
|
+
if (value === 'true') {
|
|
628
|
+
return true;
|
|
629
|
+
}
|
|
630
|
+
else if (value === 'false') {
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
385
633
|
}
|
|
386
|
-
|
|
387
|
-
return currentState;
|
|
634
|
+
return currentState;
|
|
388
635
|
};
|
|
636
|
+
// inlined sugars PredicateFilter.descendants for file size but also make it only act on editable nodes it changes the current editable state when it traveses down
|
|
389
637
|
const filterEditableDescendants = (scope, predicate, editable) => {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
638
|
+
let result = [];
|
|
639
|
+
const dom = scope.dom;
|
|
640
|
+
const children = map(dom.childNodes, SugarElement.fromDom);
|
|
641
|
+
const isEditable = (node) => isWrappedNbsp(node.dom) || !isContentEditableFalse(node);
|
|
642
|
+
each$1(children, (x) => {
|
|
643
|
+
if (editable && isEditable(x) && predicate(x)) {
|
|
644
|
+
result = result.concat([x]);
|
|
645
|
+
}
|
|
646
|
+
result = result.concat(filterEditableDescendants(x, predicate, isChildEditable(x, editable)));
|
|
647
|
+
});
|
|
648
|
+
return result;
|
|
401
649
|
};
|
|
402
650
|
const findParentElm = (elm, rootElm) => {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
651
|
+
while (elm.parentNode) {
|
|
652
|
+
if (elm.parentNode === rootElm) {
|
|
653
|
+
return rootElm;
|
|
654
|
+
}
|
|
655
|
+
elm = elm.parentNode;
|
|
406
656
|
}
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
return undefined;
|
|
657
|
+
return undefined;
|
|
410
658
|
};
|
|
411
|
-
const replaceWithSpans = text => text.replace(regExpGlobal, wrapCharWithSpan);
|
|
659
|
+
const replaceWithSpans = (text) => text.replace(regExpGlobal, wrapCharWithSpan);
|
|
412
660
|
|
|
413
661
|
const show = (editor, rootElm) => {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
662
|
+
const dom = editor.dom;
|
|
663
|
+
const nodeList = filterEditableDescendants(SugarElement.fromDom(rootElm), isMatch, editor.dom.isEditable(rootElm));
|
|
664
|
+
each$1(nodeList, (n) => {
|
|
665
|
+
var _a;
|
|
666
|
+
const parent = n.dom.parentNode;
|
|
667
|
+
if (isWrappedNbsp(parent)) {
|
|
668
|
+
add(SugarElement.fromDom(parent), nbspClass);
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
const withSpans = replaceWithSpans(dom.encode((_a = value(n)) !== null && _a !== void 0 ? _a : ''));
|
|
672
|
+
const div = dom.create('div', {}, withSpans);
|
|
673
|
+
let node;
|
|
674
|
+
while ((node = div.lastChild)) {
|
|
675
|
+
dom.insertAfter(node, n.dom);
|
|
676
|
+
}
|
|
677
|
+
editor.dom.remove(n.dom);
|
|
678
|
+
}
|
|
679
|
+
});
|
|
431
680
|
};
|
|
432
681
|
const hide = (editor, rootElm) => {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
682
|
+
const nodeList = editor.dom.select(selector, rootElm);
|
|
683
|
+
each$1(nodeList, (node) => {
|
|
684
|
+
if (isWrappedNbsp(node)) {
|
|
685
|
+
remove(SugarElement.fromDom(node), nbspClass);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
editor.dom.remove(node, true);
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
};
|
|
692
|
+
const toggle = (editor) => {
|
|
693
|
+
const body = editor.getBody();
|
|
694
|
+
const bookmark = editor.selection.getBookmark();
|
|
695
|
+
let parentNode = findParentElm(editor.selection.getNode(), body);
|
|
696
|
+
// if user does select all the parentNode will be undefined
|
|
697
|
+
parentNode = parentNode !== undefined ? parentNode : body;
|
|
698
|
+
hide(editor, parentNode);
|
|
699
|
+
show(editor, parentNode);
|
|
700
|
+
editor.selection.moveToBookmark(bookmark);
|
|
450
701
|
};
|
|
451
702
|
|
|
452
703
|
const applyVisualChars = (editor, toggleState) => {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
704
|
+
fireVisualChars(editor, toggleState.get());
|
|
705
|
+
const body = editor.getBody();
|
|
706
|
+
if (toggleState.get() === true) {
|
|
707
|
+
show(editor, body);
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
hide(editor, body);
|
|
711
|
+
}
|
|
460
712
|
};
|
|
713
|
+
// Toggle state and save selection bookmark before applying visualChars
|
|
461
714
|
const toggleVisualChars = (editor, toggleState) => {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
715
|
+
toggleState.set(!toggleState.get());
|
|
716
|
+
const bookmark = editor.selection.getBookmark();
|
|
717
|
+
applyVisualChars(editor, toggleState);
|
|
718
|
+
editor.selection.moveToBookmark(bookmark);
|
|
466
719
|
};
|
|
467
720
|
|
|
468
721
|
const register$2 = (editor, toggleState) => {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
722
|
+
editor.addCommand('mceVisualChars', () => {
|
|
723
|
+
toggleVisualChars(editor, toggleState);
|
|
724
|
+
});
|
|
472
725
|
};
|
|
473
726
|
|
|
474
|
-
const option = name => editor => editor.options.get(name);
|
|
475
|
-
const register$1 = editor => {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
727
|
+
const option = (name) => (editor) => editor.options.get(name);
|
|
728
|
+
const register$1 = (editor) => {
|
|
729
|
+
const registerOption = editor.options.register;
|
|
730
|
+
registerOption('visualchars_default_state', {
|
|
731
|
+
processor: 'boolean',
|
|
732
|
+
default: false
|
|
733
|
+
});
|
|
481
734
|
};
|
|
482
735
|
const isEnabledByDefault = option('visualchars_default_state');
|
|
483
736
|
|
|
484
737
|
const setup$1 = (editor, toggleState) => {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (isNull(timer)) {
|
|
500
|
-
timer = setTimeout(() => {
|
|
501
|
-
timer = null;
|
|
502
|
-
fn.apply(null, args);
|
|
503
|
-
}, rate);
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
return {
|
|
507
|
-
cancel,
|
|
508
|
-
throttle
|
|
509
|
-
};
|
|
738
|
+
/*
|
|
739
|
+
Note: applyVisualChars does not place a bookmark before modifying the DOM on init.
|
|
740
|
+
This will cause a loss of selection if the following conditions are met:
|
|
741
|
+
- Autofocus enabled, or editor is manually focused on init
|
|
742
|
+
- The first piece of text in the editor must be a nbsp
|
|
743
|
+
- Integrator has manually set the selection before init
|
|
744
|
+
|
|
745
|
+
Another improvement would be to ensure DOM elements aren't destroyed/recreated,
|
|
746
|
+
but rather wrapped/unwrapped when applying styling for visualchars so that selection
|
|
747
|
+
is not lost.
|
|
748
|
+
*/
|
|
749
|
+
editor.on('init', () => {
|
|
750
|
+
applyVisualChars(editor, toggleState);
|
|
751
|
+
});
|
|
510
752
|
};
|
|
511
753
|
|
|
512
754
|
const setup = (editor, toggleState) => {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
};
|
|
523
|
-
|
|
524
|
-
const toggleActiveState = (editor, enabledStated) => api => {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
755
|
+
const debouncedToggle = first(() => {
|
|
756
|
+
toggle(editor);
|
|
757
|
+
}, 300);
|
|
758
|
+
editor.on('keydown', (e) => {
|
|
759
|
+
if (toggleState.get() === true) {
|
|
760
|
+
e.keyCode === 13 ? toggle(editor) : debouncedToggle.throttle();
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
editor.on('remove', debouncedToggle.cancel);
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
const toggleActiveState = (editor, enabledStated) => (api) => {
|
|
767
|
+
api.setActive(enabledStated.get());
|
|
768
|
+
const editorEventCallback = (e) => api.setActive(e.state);
|
|
769
|
+
editor.on('VisualChars', editorEventCallback);
|
|
770
|
+
return () => editor.off('VisualChars', editorEventCallback);
|
|
529
771
|
};
|
|
530
772
|
const register = (editor, toggleState) => {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
773
|
+
const onAction = () => editor.execCommand('mceVisualChars');
|
|
774
|
+
editor.ui.registry.addToggleButton('visualchars', {
|
|
775
|
+
tooltip: 'Show invisible characters',
|
|
776
|
+
icon: 'visualchars',
|
|
777
|
+
onAction,
|
|
778
|
+
onSetup: toggleActiveState(editor, toggleState),
|
|
779
|
+
context: 'any'
|
|
780
|
+
});
|
|
781
|
+
editor.ui.registry.addToggleMenuItem('visualchars', {
|
|
782
|
+
text: 'Show invisible characters',
|
|
783
|
+
icon: 'visualchars',
|
|
784
|
+
onAction,
|
|
785
|
+
onSetup: toggleActiveState(editor, toggleState),
|
|
786
|
+
context: 'any'
|
|
787
|
+
});
|
|
544
788
|
};
|
|
545
789
|
|
|
546
790
|
var Plugin = () => {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
791
|
+
global.add('visualchars', (editor) => {
|
|
792
|
+
register$1(editor);
|
|
793
|
+
const toggleState = Cell(isEnabledByDefault(editor));
|
|
794
|
+
register$2(editor, toggleState);
|
|
795
|
+
register(editor, toggleState);
|
|
796
|
+
setup(editor, toggleState);
|
|
797
|
+
setup$1(editor, toggleState);
|
|
798
|
+
return get$2(toggleState);
|
|
799
|
+
});
|
|
556
800
|
};
|
|
557
801
|
|
|
558
802
|
Plugin();
|
|
803
|
+
/** *****
|
|
804
|
+
* DO NOT EXPORT ANYTHING
|
|
805
|
+
*
|
|
806
|
+
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
807
|
+
*******/
|
|
559
808
|
|
|
560
809
|
})();
|