@dangl/angular-material-shared 2.9.0-beta0047 → 2.9.0-beta0048
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/package.json +1 -1
- package/tinymce-assets/icons/default/icons.js +9 -46
- package/tinymce-assets/icons/default/icons.min.js +1 -1
- package/tinymce-assets/models/dom/model.js +7239 -8193
- package/tinymce-assets/models/dom/model.min.js +1 -1
- package/tinymce-assets/plugins/accordion/plugin.js +879 -1174
- package/tinymce-assets/plugins/accordion/plugin.min.js +5 -1
- package/tinymce-assets/plugins/advlist/plugin.js +200 -412
- package/tinymce-assets/plugins/advlist/plugin.min.js +5 -1
- package/tinymce-assets/plugins/anchor/plugin.js +166 -189
- package/tinymce-assets/plugins/anchor/plugin.min.js +5 -1
- package/tinymce-assets/plugins/autolink/plugin.js +220 -310
- package/tinymce-assets/plugins/autolink/plugin.min.js +5 -1
- package/tinymce-assets/plugins/autoresize/plugin.js +149 -180
- package/tinymce-assets/plugins/autoresize/plugin.min.js +5 -1
- package/tinymce-assets/plugins/autosave/plugin.js +189 -208
- package/tinymce-assets/plugins/autosave/plugin.min.js +5 -1
- package/tinymce-assets/plugins/charmap/plugin.js +1566 -905
- package/tinymce-assets/plugins/charmap/plugin.min.js +5 -1
- package/tinymce-assets/plugins/code/plugin.js +61 -73
- package/tinymce-assets/plugins/code/plugin.min.js +4 -0
- package/tinymce-assets/plugins/codesample/plugin.js +2409 -3592
- package/tinymce-assets/plugins/codesample/plugin.min.js +12 -8
- package/tinymce-assets/plugins/directionality/plugin.js +304 -545
- package/tinymce-assets/plugins/directionality/plugin.min.js +5 -1
- package/tinymce-assets/plugins/emoticons/plugin.js +488 -702
- package/tinymce-assets/plugins/emoticons/plugin.min.js +5 -1
- package/tinymce-assets/plugins/fullscreen/plugin.js +1049 -1409
- package/tinymce-assets/plugins/fullscreen/plugin.min.js +5 -1
- package/tinymce-assets/plugins/help/js/i18n/keynav/ar.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/bg_BG.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ca.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/cs.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/da.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/de.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/el.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/en.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/es.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/eu.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/fa.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/fi.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/fr_FR.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/he_IL.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/hi.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/hr.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/hu_HU.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/id.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/it.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ja.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/kk.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ko_KR.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ms.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/nb_NO.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/nl.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/pl.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_BR.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_PT.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ro.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/ru.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/sk.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/sl_SI.js +2 -5
- package/tinymce-assets/plugins/help/js/i18n/keynav/sv_SE.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/th_TH.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/tr.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/uk.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/vi.js +1 -4
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_CN.js +5 -8
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_TW.js +1 -4
- package/tinymce-assets/plugins/help/plugin.js +809 -739
- package/tinymce-assets/plugins/help/plugin.min.js +5 -1
- package/tinymce-assets/plugins/image/plugin.js +1291 -1475
- package/tinymce-assets/plugins/image/plugin.min.js +5 -1
- package/tinymce-assets/plugins/importcss/plugin.js +269 -328
- package/tinymce-assets/plugins/importcss/plugin.min.js +5 -1
- package/tinymce-assets/plugins/insertdatetime/plugin.js +141 -140
- package/tinymce-assets/plugins/insertdatetime/plugin.min.js +5 -1
- package/tinymce-assets/plugins/link/plugin.js +1084 -1419
- package/tinymce-assets/plugins/link/plugin.min.js +5 -1
- package/tinymce-assets/plugins/lists/plugin.js +1805 -2177
- package/tinymce-assets/plugins/lists/plugin.min.js +5 -1
- package/tinymce-assets/plugins/media/plugin.js +1047 -1305
- package/tinymce-assets/plugins/media/plugin.min.js +5 -1
- package/tinymce-assets/plugins/nonbreaking/plugin.js +88 -93
- package/tinymce-assets/plugins/nonbreaking/plugin.min.js +4 -0
- package/tinymce-assets/plugins/pagebreak/plugin.js +85 -91
- package/tinymce-assets/plugins/pagebreak/plugin.min.js +4 -0
- package/tinymce-assets/plugins/preview/plugin.js +74 -742
- package/tinymce-assets/plugins/preview/plugin.min.js +5 -1
- package/tinymce-assets/plugins/quickbars/plugin.js +375 -582
- package/tinymce-assets/plugins/quickbars/plugin.min.js +5 -1
- package/tinymce-assets/plugins/save/plugin.js +82 -100
- package/tinymce-assets/plugins/save/plugin.min.js +5 -1
- package/tinymce-assets/plugins/searchreplace/plugin.js +906 -1183
- package/tinymce-assets/plugins/searchreplace/plugin.min.js +5 -1
- package/tinymce-assets/plugins/table/plugin.js +3094 -3651
- package/tinymce-assets/plugins/table/plugin.min.js +5 -1
- package/tinymce-assets/plugins/template/index.js +7 -0
- package/tinymce-assets/plugins/template/plugin.js +567 -0
- package/tinymce-assets/plugins/template/plugin.min.js +5 -0
- package/tinymce-assets/plugins/visualblocks/plugin.js +63 -71
- package/tinymce-assets/plugins/visualblocks/plugin.min.js +5 -1
- package/tinymce-assets/plugins/visualchars/plugin.js +436 -685
- package/tinymce-assets/plugins/visualchars/plugin.min.js +5 -1
- package/tinymce-assets/plugins/wordcount/plugin.js +307 -382
- package/tinymce-assets/plugins/wordcount/plugin.min.js +5 -1
- package/tinymce-assets/skins/content/dark/content.css +4 -0
- package/tinymce-assets/skins/content/dark/content.js +6 -1
- package/tinymce-assets/skins/content/dark/content.min.css +4 -0
- package/tinymce-assets/skins/content/default/content.css +4 -0
- package/tinymce-assets/skins/content/default/content.js +6 -1
- package/tinymce-assets/skins/content/default/content.min.css +4 -0
- package/tinymce-assets/skins/content/document/content.css +4 -0
- package/tinymce-assets/skins/content/document/content.js +6 -1
- package/tinymce-assets/skins/content/document/content.min.css +4 -0
- package/tinymce-assets/skins/content/tinymce-5/content.css +4 -0
- package/tinymce-assets/skins/content/tinymce-5/content.js +6 -1
- package/tinymce-assets/skins/content/tinymce-5/content.min.css +4 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.css +4 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.js +6 -1
- package/tinymce-assets/skins/content/tinymce-5-dark/content.min.css +4 -0
- package/tinymce-assets/skins/content/writer/content.css +4 -0
- package/tinymce-assets/skins/content/writer/content.js +6 -1
- package/tinymce-assets/skins/content/writer/content.min.css +4 -0
- package/tinymce-assets/skins/ui/oxide/content.css +53 -148
- package/tinymce-assets/skins/ui/oxide/content.inline.css +53 -148
- package/tinymce-assets/skins/ui/oxide/content.inline.js +6 -1
- package/tinymce-assets/skins/ui/oxide/content.inline.min.css +5 -1
- package/tinymce-assets/skins/ui/oxide/content.js +6 -1
- package/tinymce-assets/skins/ui/oxide/content.min.css +5 -1
- package/tinymce-assets/skins/ui/oxide/skin.css +207 -1585
- package/tinymce-assets/skins/ui/oxide/skin.js +2 -1
- package/tinymce-assets/skins/ui/oxide/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.js +2 -1
- package/tinymce-assets/skins/ui/oxide-dark/content.css +46 -148
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.css +53 -148
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.js +6 -1
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.min.css +5 -1
- package/tinymce-assets/skins/ui/oxide-dark/content.js +6 -1
- package/tinymce-assets/skins/ui/oxide-dark/content.min.css +5 -1
- package/tinymce-assets/skins/ui/oxide-dark/skin.css +219 -1597
- package/tinymce-assets/skins/ui/oxide-dark/skin.js +2 -1
- package/tinymce-assets/skins/ui/oxide-dark/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.js +2 -1
- package/tinymce-assets/skins/ui/tinymce-5/content.css +53 -148
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.css +53 -148
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.js +6 -1
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.min.css +5 -1
- package/tinymce-assets/skins/ui/tinymce-5/content.js +6 -1
- package/tinymce-assets/skins/ui/tinymce-5/content.min.css +5 -1
- package/tinymce-assets/skins/ui/tinymce-5/skin.css +194 -1597
- package/tinymce-assets/skins/ui/tinymce-5/skin.js +2 -1
- package/tinymce-assets/skins/ui/tinymce-5/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.js +2 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.css +46 -148
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.css +53 -148
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.js +6 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.min.css +5 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.js +6 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.min.css +5 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.css +202 -1605
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.js +2 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.min.css +1 -1
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.js +2 -1
- package/tinymce-assets/themes/silver/theme.js +28439 -32466
- package/tinymce-assets/themes/silver/theme.min.js +1 -1
|
@@ -1,809 +1,560 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TinyMCE version
|
|
2
|
+
* TinyMCE version 6.8.6 (TBD)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function () {
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
const Cell = initial => {
|
|
9
|
+
let value = initial;
|
|
10
|
+
const get = () => {
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
const set = v => {
|
|
14
|
+
value = v;
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
get,
|
|
18
|
+
set
|
|
19
|
+
};
|
|
18
20
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return t;
|
|
32
|
-
}
|
|
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 };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const fireVisualChars = (editor, state) => {
|
|
32
|
+
return editor.dispatch('VisualChars', { state });
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
const hasProto = (v, constructor, predicate) => {
|
|
36
|
+
var _a;
|
|
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;
|
|
37
58
|
const isString = isType$1('string');
|
|
38
59
|
const isObject = isType$1('object');
|
|
39
60
|
const isNull = eq(null);
|
|
40
61
|
const isBoolean = isSimpleType('boolean');
|
|
41
|
-
const isNullable =
|
|
42
|
-
const isNonNullable =
|
|
43
|
-
const isFunction = isSimpleType('function');
|
|
62
|
+
const isNullable = a => a === null || a === undefined;
|
|
63
|
+
const isNonNullable = a => !isNullable(a);
|
|
44
64
|
const isNumber = isSimpleType('number');
|
|
45
65
|
|
|
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
|
-
*/
|
|
61
66
|
class Optional {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
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
|
-
}
|
|
67
|
+
constructor(tag, value) {
|
|
68
|
+
this.tag = tag;
|
|
69
|
+
this.value = value;
|
|
70
|
+
}
|
|
71
|
+
static some(value) {
|
|
72
|
+
return new Optional(true, value);
|
|
73
|
+
}
|
|
74
|
+
static none() {
|
|
75
|
+
return Optional.singletonNone;
|
|
76
|
+
}
|
|
77
|
+
fold(onNone, onSome) {
|
|
78
|
+
if (this.tag) {
|
|
79
|
+
return onSome(this.value);
|
|
80
|
+
} else {
|
|
81
|
+
return onNone();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
isSome() {
|
|
85
|
+
return this.tag;
|
|
86
|
+
}
|
|
87
|
+
isNone() {
|
|
88
|
+
return !this.tag;
|
|
89
|
+
}
|
|
90
|
+
map(mapper) {
|
|
91
|
+
if (this.tag) {
|
|
92
|
+
return Optional.some(mapper(this.value));
|
|
93
|
+
} else {
|
|
94
|
+
return Optional.none();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
bind(binder) {
|
|
98
|
+
if (this.tag) {
|
|
99
|
+
return binder(this.value);
|
|
100
|
+
} else {
|
|
101
|
+
return Optional.none();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exists(predicate) {
|
|
105
|
+
return this.tag && predicate(this.value);
|
|
106
|
+
}
|
|
107
|
+
forall(predicate) {
|
|
108
|
+
return !this.tag || predicate(this.value);
|
|
109
|
+
}
|
|
110
|
+
filter(predicate) {
|
|
111
|
+
if (!this.tag || predicate(this.value)) {
|
|
112
|
+
return this;
|
|
113
|
+
} else {
|
|
114
|
+
return Optional.none();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
getOr(replacement) {
|
|
118
|
+
return this.tag ? this.value : replacement;
|
|
119
|
+
}
|
|
120
|
+
or(replacement) {
|
|
121
|
+
return this.tag ? this : replacement;
|
|
122
|
+
}
|
|
123
|
+
getOrThunk(thunk) {
|
|
124
|
+
return this.tag ? this.value : thunk();
|
|
125
|
+
}
|
|
126
|
+
orThunk(thunk) {
|
|
127
|
+
return this.tag ? this : thunk();
|
|
128
|
+
}
|
|
129
|
+
getOrDie(message) {
|
|
130
|
+
if (!this.tag) {
|
|
131
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
132
|
+
} else {
|
|
133
|
+
return this.value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
static from(value) {
|
|
137
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
138
|
+
}
|
|
139
|
+
getOrNull() {
|
|
140
|
+
return this.tag ? this.value : null;
|
|
141
|
+
}
|
|
142
|
+
getOrUndefined() {
|
|
143
|
+
return this.value;
|
|
144
|
+
}
|
|
145
|
+
each(worker) {
|
|
146
|
+
if (this.tag) {
|
|
147
|
+
worker(this.value);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
toArray() {
|
|
151
|
+
return this.tag ? [this.value] : [];
|
|
152
|
+
}
|
|
153
|
+
toString() {
|
|
154
|
+
return this.tag ? `some(${ this.value })` : 'none()';
|
|
155
|
+
}
|
|
292
156
|
}
|
|
293
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
294
|
-
// reuse the same object
|
|
295
157
|
Optional.singletonNone = new Optional(false);
|
|
296
158
|
|
|
297
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
298
|
-
const nativeSlice = Array.prototype.slice;
|
|
299
159
|
const map = (xs, f) => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
return r;
|
|
160
|
+
const len = xs.length;
|
|
161
|
+
const r = new Array(len);
|
|
162
|
+
for (let i = 0; i < len; i++) {
|
|
163
|
+
const x = xs[i];
|
|
164
|
+
r[i] = f(x, i);
|
|
165
|
+
}
|
|
166
|
+
return r;
|
|
309
167
|
};
|
|
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 {
|
|
313
168
|
const each$1 = (xs, f) => {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
169
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
170
|
+
const x = xs[i];
|
|
171
|
+
f(x, i);
|
|
172
|
+
}
|
|
318
173
|
};
|
|
319
174
|
const filter = (xs, pred) => {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
175
|
+
const r = [];
|
|
176
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
177
|
+
const x = xs[i];
|
|
178
|
+
if (pred(x, i)) {
|
|
179
|
+
r.push(x);
|
|
326
180
|
}
|
|
327
|
-
|
|
181
|
+
}
|
|
182
|
+
return r;
|
|
328
183
|
};
|
|
329
|
-
isFunction(Array.from) ? Array.from : (x) => nativeSlice.call(x);
|
|
330
184
|
|
|
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
|
|
335
185
|
const keys = Object.keys;
|
|
336
186
|
const each = (obj, f) => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
187
|
+
const props = keys(obj);
|
|
188
|
+
for (let k = 0, len = props.length; k < len; k++) {
|
|
189
|
+
const i = props[k];
|
|
190
|
+
const x = obj[i];
|
|
191
|
+
f(x, i);
|
|
192
|
+
}
|
|
343
193
|
};
|
|
344
194
|
|
|
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
|
|
361
195
|
const Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
362
196
|
|
|
363
|
-
/** path :: ([String], JsObj?) -> JsObj */
|
|
364
197
|
const path = (parts, scope) => {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
198
|
+
let o = scope !== undefined && scope !== null ? scope : Global;
|
|
199
|
+
for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
|
|
200
|
+
o = o[parts[i]];
|
|
201
|
+
}
|
|
202
|
+
return o;
|
|
370
203
|
};
|
|
371
|
-
/** resolve :: (String, JsObj?) -> JsObj */
|
|
372
204
|
const resolve = (p, scope) => {
|
|
373
|
-
|
|
374
|
-
|
|
205
|
+
const parts = p.split('.');
|
|
206
|
+
return path(parts, scope);
|
|
375
207
|
};
|
|
376
208
|
|
|
377
|
-
|
|
378
|
-
|
|
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
|
-
};
|
|
399
|
-
};
|
|
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
|
-
};
|
|
209
|
+
const unsafe = (name, scope) => {
|
|
210
|
+
return resolve(name, scope);
|
|
410
211
|
};
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
212
|
+
const getOrDie = (name, scope) => {
|
|
213
|
+
const actual = unsafe(name, scope);
|
|
214
|
+
if (actual === undefined || actual === null) {
|
|
215
|
+
throw new Error(name + ' not available on this browser');
|
|
216
|
+
}
|
|
217
|
+
return actual;
|
|
414
218
|
};
|
|
415
219
|
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
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
|
-
};
|
|
220
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
221
|
+
const sandHTMLElement = scope => {
|
|
222
|
+
return getOrDie('HTMLElement', scope);
|
|
446
223
|
};
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
fromHtml,
|
|
451
|
-
fromTag,
|
|
452
|
-
fromText,
|
|
453
|
-
fromDom,
|
|
454
|
-
fromPoint
|
|
224
|
+
const isPrototypeOf = x => {
|
|
225
|
+
const scope = resolve('ownerDocument.defaultView', x);
|
|
226
|
+
return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
|
|
455
227
|
};
|
|
456
228
|
|
|
457
229
|
const ELEMENT = 1;
|
|
458
230
|
const TEXT = 3;
|
|
459
231
|
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const
|
|
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);
|
|
232
|
+
const type = element => element.dom.nodeType;
|
|
233
|
+
const value = element => element.dom.nodeValue;
|
|
234
|
+
const isType = t => element => type(element) === t;
|
|
235
|
+
const isHTMLElement = element => isElement(element) && isPrototypeOf(element.dom);
|
|
494
236
|
const isElement = isType(ELEMENT);
|
|
495
237
|
const isText = isType(TEXT);
|
|
496
238
|
|
|
497
239
|
const rawSet = (dom, key, value) => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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
|
-
}
|
|
240
|
+
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
241
|
+
dom.setAttribute(key, value + '');
|
|
242
|
+
} else {
|
|
243
|
+
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
244
|
+
throw new Error('Attribute value was not simple');
|
|
245
|
+
}
|
|
511
246
|
};
|
|
512
247
|
const set = (element, key, value) => {
|
|
513
|
-
|
|
248
|
+
rawSet(element.dom, key, value);
|
|
514
249
|
};
|
|
515
250
|
const get$1 = (element, key) => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
return v === null ? undefined : v;
|
|
251
|
+
const v = element.dom.getAttribute(key);
|
|
252
|
+
return v === null ? undefined : v;
|
|
519
253
|
};
|
|
520
254
|
const remove$3 = (element, key) => {
|
|
521
|
-
|
|
255
|
+
element.dom.removeAttribute(key);
|
|
522
256
|
};
|
|
523
257
|
|
|
524
|
-
// Methods for handling attributes that contain a list of values <div foo="alpha beta theta">
|
|
525
258
|
const read = (element, attr) => {
|
|
526
|
-
|
|
527
|
-
|
|
259
|
+
const value = get$1(element, attr);
|
|
260
|
+
return value === undefined || value === '' ? [] : value.split(' ');
|
|
528
261
|
};
|
|
529
262
|
const add$2 = (element, attr, id) => {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
263
|
+
const old = read(element, attr);
|
|
264
|
+
const nu = old.concat([id]);
|
|
265
|
+
set(element, attr, nu.join(' '));
|
|
266
|
+
return true;
|
|
534
267
|
};
|
|
535
268
|
const remove$2 = (element, attr, id) => {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return false;
|
|
269
|
+
const nu = filter(read(element, attr), v => v !== id);
|
|
270
|
+
if (nu.length > 0) {
|
|
271
|
+
set(element, attr, nu.join(' '));
|
|
272
|
+
} else {
|
|
273
|
+
remove$3(element, attr);
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
544
276
|
};
|
|
545
277
|
|
|
546
|
-
|
|
547
|
-
const
|
|
548
|
-
const get = (element) => read(element, 'class');
|
|
278
|
+
const supports = element => element.dom.classList !== undefined;
|
|
279
|
+
const get = element => read(element, 'class');
|
|
549
280
|
const add$1 = (element, clazz) => add$2(element, 'class', clazz);
|
|
550
281
|
const remove$1 = (element, clazz) => remove$2(element, 'class', clazz);
|
|
551
282
|
|
|
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
|
-
*/
|
|
559
283
|
const add = (element, clazz) => {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
// No more classes left, remove the class attribute as well
|
|
572
|
-
remove$3(element, 'class');
|
|
573
|
-
}
|
|
284
|
+
if (supports(element)) {
|
|
285
|
+
element.dom.classList.add(clazz);
|
|
286
|
+
} else {
|
|
287
|
+
add$1(element, clazz);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const cleanClass = element => {
|
|
291
|
+
const classList = supports(element) ? element.dom.classList : get(element);
|
|
292
|
+
if (classList.length === 0) {
|
|
293
|
+
remove$3(element, 'class');
|
|
294
|
+
}
|
|
574
295
|
};
|
|
575
296
|
const remove = (element, clazz) => {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
cleanClass(element);
|
|
297
|
+
if (supports(element)) {
|
|
298
|
+
const classList = element.dom.classList;
|
|
299
|
+
classList.remove(clazz);
|
|
300
|
+
} else {
|
|
301
|
+
remove$1(element, clazz);
|
|
302
|
+
}
|
|
303
|
+
cleanClass(element);
|
|
584
304
|
};
|
|
585
305
|
|
|
586
|
-
const
|
|
306
|
+
const fromHtml = (html, scope) => {
|
|
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
|
+
};
|
|
587
341
|
|
|
588
342
|
const charMap = {
|
|
589
|
-
|
|
590
|
-
|
|
343
|
+
'\xA0': 'nbsp',
|
|
344
|
+
'\xAD': 'shy'
|
|
591
345
|
};
|
|
592
346
|
const charMapToRegExp = (charMap, global) => {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
};
|
|
599
|
-
const charMapToSelector =
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
347
|
+
let regExp = '';
|
|
348
|
+
each(charMap, (_value, key) => {
|
|
349
|
+
regExp += key;
|
|
350
|
+
});
|
|
351
|
+
return new RegExp('[' + regExp + ']', global ? 'g' : '');
|
|
352
|
+
};
|
|
353
|
+
const charMapToSelector = charMap => {
|
|
354
|
+
let selector = '';
|
|
355
|
+
each(charMap, value => {
|
|
356
|
+
if (selector) {
|
|
357
|
+
selector += ',';
|
|
358
|
+
}
|
|
359
|
+
selector += 'span.mce-' + value;
|
|
360
|
+
});
|
|
361
|
+
return selector;
|
|
608
362
|
};
|
|
609
363
|
const regExp = charMapToRegExp(charMap);
|
|
610
364
|
const regExpGlobal = charMapToRegExp(charMap, true);
|
|
611
365
|
const selector = charMapToSelector(charMap);
|
|
612
366
|
const nbspClass = 'mce-nbsp';
|
|
613
367
|
|
|
614
|
-
const
|
|
368
|
+
const getRaw = element => element.dom.contentEditable;
|
|
615
369
|
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
370
|
+
const wrapCharWithSpan = value => '<span data-mce-bogus="1" class="mce-' + charMap[value] + '">' + value + '</span>';
|
|
371
|
+
|
|
372
|
+
const isWrappedNbsp = node => node.nodeName.toLowerCase() === 'span' && node.classList.contains('mce-nbsp-wrap');
|
|
373
|
+
const isMatch = n => {
|
|
374
|
+
const value$1 = value(n);
|
|
375
|
+
return isText(n) && isString(value$1) && regExp.test(value$1);
|
|
622
376
|
};
|
|
623
|
-
const isContentEditableFalse =
|
|
377
|
+
const isContentEditableFalse = node => isHTMLElement(node) && getRaw(node) === 'false';
|
|
624
378
|
const isChildEditable = (node, currentState) => {
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return false;
|
|
632
|
-
}
|
|
379
|
+
if (isHTMLElement(node) && !isWrappedNbsp(node.dom)) {
|
|
380
|
+
const value = getRaw(node);
|
|
381
|
+
if (value === 'true') {
|
|
382
|
+
return true;
|
|
383
|
+
} else if (value === 'false') {
|
|
384
|
+
return false;
|
|
633
385
|
}
|
|
634
|
-
|
|
386
|
+
}
|
|
387
|
+
return currentState;
|
|
635
388
|
};
|
|
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
|
|
637
389
|
const filterEditableDescendants = (scope, predicate, editable) => {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
390
|
+
let result = [];
|
|
391
|
+
const dom = scope.dom;
|
|
392
|
+
const children = map(dom.childNodes, SugarElement.fromDom);
|
|
393
|
+
const isEditable = node => isWrappedNbsp(node.dom) || !isContentEditableFalse(node);
|
|
394
|
+
each$1(children, x => {
|
|
395
|
+
if (editable && isEditable(x) && predicate(x)) {
|
|
396
|
+
result = result.concat([x]);
|
|
397
|
+
}
|
|
398
|
+
result = result.concat(filterEditableDescendants(x, predicate, isChildEditable(x, editable)));
|
|
399
|
+
});
|
|
400
|
+
return result;
|
|
649
401
|
};
|
|
650
402
|
const findParentElm = (elm, rootElm) => {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}
|
|
655
|
-
elm = elm.parentNode;
|
|
403
|
+
while (elm.parentNode) {
|
|
404
|
+
if (elm.parentNode === rootElm) {
|
|
405
|
+
return rootElm;
|
|
656
406
|
}
|
|
657
|
-
|
|
407
|
+
elm = elm.parentNode;
|
|
408
|
+
}
|
|
409
|
+
return undefined;
|
|
658
410
|
};
|
|
659
|
-
const replaceWithSpans =
|
|
411
|
+
const replaceWithSpans = text => text.replace(regExpGlobal, wrapCharWithSpan);
|
|
660
412
|
|
|
661
413
|
const show = (editor, rootElm) => {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
});
|
|
414
|
+
const dom = editor.dom;
|
|
415
|
+
const nodeList = filterEditableDescendants(SugarElement.fromDom(rootElm), isMatch, editor.dom.isEditable(rootElm));
|
|
416
|
+
each$1(nodeList, n => {
|
|
417
|
+
var _a;
|
|
418
|
+
const parent = n.dom.parentNode;
|
|
419
|
+
if (isWrappedNbsp(parent)) {
|
|
420
|
+
add(SugarElement.fromDom(parent), nbspClass);
|
|
421
|
+
} else {
|
|
422
|
+
const withSpans = replaceWithSpans(dom.encode((_a = value(n)) !== null && _a !== void 0 ? _a : ''));
|
|
423
|
+
const div = dom.create('div', {}, withSpans);
|
|
424
|
+
let node;
|
|
425
|
+
while (node = div.lastChild) {
|
|
426
|
+
dom.insertAfter(node, n.dom);
|
|
427
|
+
}
|
|
428
|
+
editor.dom.remove(n.dom);
|
|
429
|
+
}
|
|
430
|
+
});
|
|
680
431
|
};
|
|
681
432
|
const hide = (editor, rootElm) => {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
show(editor, parentNode);
|
|
700
|
-
editor.selection.moveToBookmark(bookmark);
|
|
433
|
+
const nodeList = editor.dom.select(selector, rootElm);
|
|
434
|
+
each$1(nodeList, node => {
|
|
435
|
+
if (isWrappedNbsp(node)) {
|
|
436
|
+
remove(SugarElement.fromDom(node), nbspClass);
|
|
437
|
+
} else {
|
|
438
|
+
editor.dom.remove(node, true);
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
const toggle = editor => {
|
|
443
|
+
const body = editor.getBody();
|
|
444
|
+
const bookmark = editor.selection.getBookmark();
|
|
445
|
+
let parentNode = findParentElm(editor.selection.getNode(), body);
|
|
446
|
+
parentNode = parentNode !== undefined ? parentNode : body;
|
|
447
|
+
hide(editor, parentNode);
|
|
448
|
+
show(editor, parentNode);
|
|
449
|
+
editor.selection.moveToBookmark(bookmark);
|
|
701
450
|
};
|
|
702
451
|
|
|
703
452
|
const applyVisualChars = (editor, toggleState) => {
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
453
|
+
fireVisualChars(editor, toggleState.get());
|
|
454
|
+
const body = editor.getBody();
|
|
455
|
+
if (toggleState.get() === true) {
|
|
456
|
+
show(editor, body);
|
|
457
|
+
} else {
|
|
458
|
+
hide(editor, body);
|
|
459
|
+
}
|
|
712
460
|
};
|
|
713
|
-
// Toggle state and save selection bookmark before applying visualChars
|
|
714
461
|
const toggleVisualChars = (editor, toggleState) => {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
462
|
+
toggleState.set(!toggleState.get());
|
|
463
|
+
const bookmark = editor.selection.getBookmark();
|
|
464
|
+
applyVisualChars(editor, toggleState);
|
|
465
|
+
editor.selection.moveToBookmark(bookmark);
|
|
719
466
|
};
|
|
720
467
|
|
|
721
468
|
const register$2 = (editor, toggleState) => {
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
469
|
+
editor.addCommand('mceVisualChars', () => {
|
|
470
|
+
toggleVisualChars(editor, toggleState);
|
|
471
|
+
});
|
|
725
472
|
};
|
|
726
473
|
|
|
727
|
-
const option =
|
|
728
|
-
const register$1 =
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
474
|
+
const option = name => editor => editor.options.get(name);
|
|
475
|
+
const register$1 = editor => {
|
|
476
|
+
const registerOption = editor.options.register;
|
|
477
|
+
registerOption('visualchars_default_state', {
|
|
478
|
+
processor: 'boolean',
|
|
479
|
+
default: false
|
|
480
|
+
});
|
|
734
481
|
};
|
|
735
482
|
const isEnabledByDefault = option('visualchars_default_state');
|
|
736
483
|
|
|
737
484
|
const setup$1 = (editor, toggleState) => {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
485
|
+
editor.on('init', () => {
|
|
486
|
+
applyVisualChars(editor, toggleState);
|
|
487
|
+
});
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const first = (fn, rate) => {
|
|
491
|
+
let timer = null;
|
|
492
|
+
const cancel = () => {
|
|
493
|
+
if (!isNull(timer)) {
|
|
494
|
+
clearTimeout(timer);
|
|
495
|
+
timer = null;
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
const throttle = (...args) => {
|
|
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
|
+
};
|
|
752
510
|
};
|
|
753
511
|
|
|
754
512
|
const setup = (editor, toggleState) => {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
const toggleActiveState = (editor, enabledStated) =>
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
513
|
+
const debouncedToggle = first(() => {
|
|
514
|
+
toggle(editor);
|
|
515
|
+
}, 300);
|
|
516
|
+
editor.on('keydown', e => {
|
|
517
|
+
if (toggleState.get() === true) {
|
|
518
|
+
e.keyCode === 13 ? toggle(editor) : debouncedToggle.throttle();
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
editor.on('remove', debouncedToggle.cancel);
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
const toggleActiveState = (editor, enabledStated) => api => {
|
|
525
|
+
api.setActive(enabledStated.get());
|
|
526
|
+
const editorEventCallback = e => api.setActive(e.state);
|
|
527
|
+
editor.on('VisualChars', editorEventCallback);
|
|
528
|
+
return () => editor.off('VisualChars', editorEventCallback);
|
|
771
529
|
};
|
|
772
530
|
const register = (editor, toggleState) => {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
context: 'any'
|
|
787
|
-
});
|
|
531
|
+
const onAction = () => editor.execCommand('mceVisualChars');
|
|
532
|
+
editor.ui.registry.addToggleButton('visualchars', {
|
|
533
|
+
tooltip: 'Show invisible characters',
|
|
534
|
+
icon: 'visualchars',
|
|
535
|
+
onAction,
|
|
536
|
+
onSetup: toggleActiveState(editor, toggleState)
|
|
537
|
+
});
|
|
538
|
+
editor.ui.registry.addToggleMenuItem('visualchars', {
|
|
539
|
+
text: 'Show invisible characters',
|
|
540
|
+
icon: 'visualchars',
|
|
541
|
+
onAction,
|
|
542
|
+
onSetup: toggleActiveState(editor, toggleState)
|
|
543
|
+
});
|
|
788
544
|
};
|
|
789
545
|
|
|
790
546
|
var Plugin = () => {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
547
|
+
global.add('visualchars', editor => {
|
|
548
|
+
register$1(editor);
|
|
549
|
+
const toggleState = Cell(isEnabledByDefault(editor));
|
|
550
|
+
register$2(editor, toggleState);
|
|
551
|
+
register(editor, toggleState);
|
|
552
|
+
setup(editor, toggleState);
|
|
553
|
+
setup$1(editor, toggleState);
|
|
554
|
+
return get$2(toggleState);
|
|
555
|
+
});
|
|
800
556
|
};
|
|
801
557
|
|
|
802
558
|
Plugin();
|
|
803
|
-
/** *****
|
|
804
|
-
* DO NOT EXPORT ANYTHING
|
|
805
|
-
*
|
|
806
|
-
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
807
|
-
*******/
|
|
808
559
|
|
|
809
560
|
})();
|