@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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TinyMCE version
|
|
2
|
+
* TinyMCE version 6.8.6 (TBD)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
(function () {
|
|
@@ -7,630 +7,389 @@
|
|
|
7
7
|
|
|
8
8
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
9
9
|
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-wrapper-object-types */
|
|
11
10
|
const hasProto = (v, constructor, predicate) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
19
|
-
}
|
|
11
|
+
var _a;
|
|
12
|
+
if (predicate(v, constructor.prototype)) {
|
|
13
|
+
return true;
|
|
14
|
+
} else {
|
|
15
|
+
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
16
|
+
}
|
|
20
17
|
};
|
|
21
|
-
const typeOf =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
else {
|
|
33
|
-
return t;
|
|
34
|
-
}
|
|
18
|
+
const typeOf = x => {
|
|
19
|
+
const t = typeof x;
|
|
20
|
+
if (x === null) {
|
|
21
|
+
return 'null';
|
|
22
|
+
} else if (t === 'object' && Array.isArray(x)) {
|
|
23
|
+
return 'array';
|
|
24
|
+
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
25
|
+
return 'string';
|
|
26
|
+
} else {
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
35
29
|
};
|
|
36
|
-
const isType$1 =
|
|
37
|
-
const isSimpleType =
|
|
30
|
+
const isType$1 = type => value => typeOf(value) === type;
|
|
31
|
+
const isSimpleType = type => value => typeof value === type;
|
|
38
32
|
const isString = isType$1('string');
|
|
39
33
|
const isBoolean = isSimpleType('boolean');
|
|
40
|
-
const isNullable =
|
|
41
|
-
const isNonNullable =
|
|
34
|
+
const isNullable = a => a === null || a === undefined;
|
|
35
|
+
const isNonNullable = a => !isNullable(a);
|
|
42
36
|
const isFunction = isSimpleType('function');
|
|
43
37
|
const isNumber = isSimpleType('number');
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
};
|
|
39
|
+
const compose1 = (fbc, fab) => a => fbc(fab(a));
|
|
40
|
+
const constant = value => {
|
|
41
|
+
return () => {
|
|
42
|
+
return value;
|
|
43
|
+
};
|
|
51
44
|
};
|
|
52
45
|
const never = constant(false);
|
|
53
46
|
|
|
54
|
-
/**
|
|
55
|
-
* The `Optional` type represents a value (of any type) that potentially does
|
|
56
|
-
* not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
|
|
57
|
-
* value does exist) or a `None` (in which case the value does not exist). This
|
|
58
|
-
* module defines a whole lot of FP-inspired utility functions for dealing with
|
|
59
|
-
* `Optional` objects.
|
|
60
|
-
*
|
|
61
|
-
* Comparison with null or undefined:
|
|
62
|
-
* - We don't get fancy null coalescing operators with `Optional`
|
|
63
|
-
* - We do get fancy helper functions with `Optional`
|
|
64
|
-
* - `Optional` support nesting, and allow for the type to still be nullable (or
|
|
65
|
-
* another `Optional`)
|
|
66
|
-
* - There is no option to turn off strict-optional-checks like there is for
|
|
67
|
-
* strict-null-checks
|
|
68
|
-
*/
|
|
69
47
|
class Optional {
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return this.tag && predicate(this.value);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* For a given predicate, this function finds out if **all** the values inside
|
|
163
|
-
* this `Optional` object meet the predicate. In practice, this means that
|
|
164
|
-
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
165
|
-
* objects do meet the predicate).
|
|
166
|
-
*/
|
|
167
|
-
forall(predicate) {
|
|
168
|
-
return !this.tag || predicate(this.value);
|
|
169
|
-
}
|
|
170
|
-
filter(predicate) {
|
|
171
|
-
if (!this.tag || predicate(this.value)) {
|
|
172
|
-
return this;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
return Optional.none();
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
// --- Getters ---
|
|
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.
|
|
183
|
-
*/
|
|
184
|
-
getOr(replacement) {
|
|
185
|
-
return this.tag ? this.value : replacement;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
189
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
190
|
-
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
191
|
-
* `Optional` - meaning that this method will always return an `Optional`.
|
|
192
|
-
*/
|
|
193
|
-
or(replacement) {
|
|
194
|
-
return this.tag ? this : replacement;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
198
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
199
|
-
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
200
|
-
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
201
|
-
* pass a function which (if called) will **return** the `value` you want to
|
|
202
|
-
* use.
|
|
203
|
-
*/
|
|
204
|
-
getOrThunk(thunk) {
|
|
205
|
-
return this.tag ? this.value : thunk();
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
209
|
-
* `replacement` value if the provided Optional object does not contain a
|
|
210
|
-
* value.
|
|
211
|
-
*
|
|
212
|
-
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
213
|
-
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
214
|
-
* (if called) will **return** the `value` you want to use.
|
|
215
|
-
*
|
|
216
|
-
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
217
|
-
* `Optional`, meaning that this method will always return an `Optional`.
|
|
218
|
-
*/
|
|
219
|
-
orThunk(thunk) {
|
|
220
|
-
return this.tag ? this : thunk();
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Get the value out of the inside of the `Optional` object, throwing an
|
|
224
|
-
* exception if the provided `Optional` object does not contain a value.
|
|
225
|
-
*
|
|
226
|
-
* WARNING:
|
|
227
|
-
* You should only be using this function if you know that the `Optional`
|
|
228
|
-
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
229
|
-
* code, which is bad).
|
|
230
|
-
*
|
|
231
|
-
* In tests this is more acceptable.
|
|
232
|
-
*
|
|
233
|
-
* Prefer other methods to this, such as `.each`.
|
|
234
|
-
*/
|
|
235
|
-
getOrDie(message) {
|
|
236
|
-
if (!this.tag) {
|
|
237
|
-
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
return this.value;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// --- Interop with null and undefined ---
|
|
244
|
-
/**
|
|
245
|
-
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
246
|
-
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
247
|
-
* to `Some`.
|
|
248
|
-
*/
|
|
249
|
-
static from(value) {
|
|
250
|
-
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Converts an `Optional` to a nullable type, by getting the value if it
|
|
254
|
-
* exists, or returning `null` if it does not.
|
|
255
|
-
*/
|
|
256
|
-
getOrNull() {
|
|
257
|
-
return this.tag ? this.value : null;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Converts an `Optional` to an undefined-able type, by getting the value if
|
|
261
|
-
* it exists, or returning `undefined` if it does not.
|
|
262
|
-
*/
|
|
263
|
-
getOrUndefined() {
|
|
264
|
-
return this.value;
|
|
265
|
-
}
|
|
266
|
-
// --- Utilities ---
|
|
267
|
-
/**
|
|
268
|
-
* If the `Optional` contains a value, perform an action on that value.
|
|
269
|
-
* Unlike the rest of the methods on this type, `.each` has side-effects. If
|
|
270
|
-
* you want to transform an `Optional<T>` **into** something, then this is not
|
|
271
|
-
* the method for you. If you want to use an `Optional<T>` to **do**
|
|
272
|
-
* something, then this is the method for you - provided you're okay with not
|
|
273
|
-
* doing anything in the case where the `Optional` doesn't have a value inside
|
|
274
|
-
* it. If you're not sure whether your use-case fits into transforming
|
|
275
|
-
* **into** something or **doing** something, check whether it has a return
|
|
276
|
-
* value. If it does, you should be performing a transform.
|
|
277
|
-
*/
|
|
278
|
-
each(worker) {
|
|
279
|
-
if (this.tag) {
|
|
280
|
-
worker(this.value);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Turn the `Optional` object into an array that contains all of the values
|
|
285
|
-
* stored inside the `Optional`. In practice, this means the output will have
|
|
286
|
-
* either 0 or 1 elements.
|
|
287
|
-
*/
|
|
288
|
-
toArray() {
|
|
289
|
-
return this.tag ? [this.value] : [];
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Turn the `Optional` object into a string for debugging or printing. Not
|
|
293
|
-
* recommended for production code, but good for debugging. Also note that
|
|
294
|
-
* these days an `Optional` object can be logged to the console directly, and
|
|
295
|
-
* its inner value (if it exists) will be visible.
|
|
296
|
-
*/
|
|
297
|
-
toString() {
|
|
298
|
-
return this.tag ? `some(${this.value})` : 'none()';
|
|
299
|
-
}
|
|
48
|
+
constructor(tag, value) {
|
|
49
|
+
this.tag = tag;
|
|
50
|
+
this.value = value;
|
|
51
|
+
}
|
|
52
|
+
static some(value) {
|
|
53
|
+
return new Optional(true, value);
|
|
54
|
+
}
|
|
55
|
+
static none() {
|
|
56
|
+
return Optional.singletonNone;
|
|
57
|
+
}
|
|
58
|
+
fold(onNone, onSome) {
|
|
59
|
+
if (this.tag) {
|
|
60
|
+
return onSome(this.value);
|
|
61
|
+
} else {
|
|
62
|
+
return onNone();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
isSome() {
|
|
66
|
+
return this.tag;
|
|
67
|
+
}
|
|
68
|
+
isNone() {
|
|
69
|
+
return !this.tag;
|
|
70
|
+
}
|
|
71
|
+
map(mapper) {
|
|
72
|
+
if (this.tag) {
|
|
73
|
+
return Optional.some(mapper(this.value));
|
|
74
|
+
} else {
|
|
75
|
+
return Optional.none();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
bind(binder) {
|
|
79
|
+
if (this.tag) {
|
|
80
|
+
return binder(this.value);
|
|
81
|
+
} else {
|
|
82
|
+
return Optional.none();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exists(predicate) {
|
|
86
|
+
return this.tag && predicate(this.value);
|
|
87
|
+
}
|
|
88
|
+
forall(predicate) {
|
|
89
|
+
return !this.tag || predicate(this.value);
|
|
90
|
+
}
|
|
91
|
+
filter(predicate) {
|
|
92
|
+
if (!this.tag || predicate(this.value)) {
|
|
93
|
+
return this;
|
|
94
|
+
} else {
|
|
95
|
+
return Optional.none();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
getOr(replacement) {
|
|
99
|
+
return this.tag ? this.value : replacement;
|
|
100
|
+
}
|
|
101
|
+
or(replacement) {
|
|
102
|
+
return this.tag ? this : replacement;
|
|
103
|
+
}
|
|
104
|
+
getOrThunk(thunk) {
|
|
105
|
+
return this.tag ? this.value : thunk();
|
|
106
|
+
}
|
|
107
|
+
orThunk(thunk) {
|
|
108
|
+
return this.tag ? this : thunk();
|
|
109
|
+
}
|
|
110
|
+
getOrDie(message) {
|
|
111
|
+
if (!this.tag) {
|
|
112
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
113
|
+
} else {
|
|
114
|
+
return this.value;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
static from(value) {
|
|
118
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
119
|
+
}
|
|
120
|
+
getOrNull() {
|
|
121
|
+
return this.tag ? this.value : null;
|
|
122
|
+
}
|
|
123
|
+
getOrUndefined() {
|
|
124
|
+
return this.value;
|
|
125
|
+
}
|
|
126
|
+
each(worker) {
|
|
127
|
+
if (this.tag) {
|
|
128
|
+
worker(this.value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
toArray() {
|
|
132
|
+
return this.tag ? [this.value] : [];
|
|
133
|
+
}
|
|
134
|
+
toString() {
|
|
135
|
+
return this.tag ? `some(${ this.value })` : 'none()';
|
|
136
|
+
}
|
|
300
137
|
}
|
|
301
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
302
|
-
// reuse the same object
|
|
303
138
|
Optional.singletonNone = new Optional(false);
|
|
304
139
|
|
|
305
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
306
|
-
const nativeSlice = Array.prototype.slice;
|
|
307
140
|
const map = (xs, f) => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
return r;
|
|
141
|
+
const len = xs.length;
|
|
142
|
+
const r = new Array(len);
|
|
143
|
+
for (let i = 0; i < len; i++) {
|
|
144
|
+
const x = xs[i];
|
|
145
|
+
r[i] = f(x, i);
|
|
146
|
+
}
|
|
147
|
+
return r;
|
|
317
148
|
};
|
|
318
|
-
// Unwound implementing other functions in terms of each.
|
|
319
|
-
// The code size is roughly the same, and it should allow for better optimisation.
|
|
320
|
-
// const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
|
|
321
149
|
const each = (xs, f) => {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
150
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
151
|
+
const x = xs[i];
|
|
152
|
+
f(x, i);
|
|
153
|
+
}
|
|
326
154
|
};
|
|
327
155
|
const filter = (xs, pred) => {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
156
|
+
const r = [];
|
|
157
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
158
|
+
const x = xs[i];
|
|
159
|
+
if (pred(x, i)) {
|
|
160
|
+
r.push(x);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return r;
|
|
336
164
|
};
|
|
337
|
-
|
|
165
|
+
|
|
166
|
+
const DOCUMENT = 9;
|
|
167
|
+
const DOCUMENT_FRAGMENT = 11;
|
|
168
|
+
const ELEMENT = 1;
|
|
169
|
+
const TEXT = 3;
|
|
338
170
|
|
|
339
171
|
const fromHtml = (html, scope) => {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return fromDom(div.childNodes[0]);
|
|
172
|
+
const doc = scope || document;
|
|
173
|
+
const div = doc.createElement('div');
|
|
174
|
+
div.innerHTML = html;
|
|
175
|
+
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
176
|
+
const message = 'HTML does not have a single root node';
|
|
177
|
+
console.error(message, html);
|
|
178
|
+
throw new Error(message);
|
|
179
|
+
}
|
|
180
|
+
return fromDom(div.childNodes[0]);
|
|
350
181
|
};
|
|
351
182
|
const fromTag = (tag, scope) => {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
183
|
+
const doc = scope || document;
|
|
184
|
+
const node = doc.createElement(tag);
|
|
185
|
+
return fromDom(node);
|
|
355
186
|
};
|
|
356
187
|
const fromText = (text, scope) => {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
188
|
+
const doc = scope || document;
|
|
189
|
+
const node = doc.createTextNode(text);
|
|
190
|
+
return fromDom(node);
|
|
360
191
|
};
|
|
361
|
-
const fromDom =
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return {
|
|
367
|
-
dom: node
|
|
368
|
-
};
|
|
192
|
+
const fromDom = node => {
|
|
193
|
+
if (node === null || node === undefined) {
|
|
194
|
+
throw new Error('Node cannot be null or undefined');
|
|
195
|
+
}
|
|
196
|
+
return { dom: node };
|
|
369
197
|
};
|
|
370
198
|
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
371
|
-
// tslint:disable-next-line:variable-name
|
|
372
199
|
const SugarElement = {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
200
|
+
fromHtml,
|
|
201
|
+
fromTag,
|
|
202
|
+
fromText,
|
|
203
|
+
fromDom,
|
|
204
|
+
fromPoint
|
|
378
205
|
};
|
|
379
206
|
|
|
380
|
-
const DOCUMENT_FRAGMENT = 11;
|
|
381
|
-
const ELEMENT = 1;
|
|
382
|
-
const TEXT = 3;
|
|
383
|
-
|
|
384
207
|
const is = (element, selector) => {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
return elem.mozMatchesSelector(selector);
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
throw new Error('Browser lacks native selectors');
|
|
406
|
-
} // unfortunately we can't throw this on startup :(
|
|
407
|
-
}
|
|
208
|
+
const dom = element.dom;
|
|
209
|
+
if (dom.nodeType !== ELEMENT) {
|
|
210
|
+
return false;
|
|
211
|
+
} else {
|
|
212
|
+
const elem = dom;
|
|
213
|
+
if (elem.matches !== undefined) {
|
|
214
|
+
return elem.matches(selector);
|
|
215
|
+
} else if (elem.msMatchesSelector !== undefined) {
|
|
216
|
+
return elem.msMatchesSelector(selector);
|
|
217
|
+
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
218
|
+
return elem.webkitMatchesSelector(selector);
|
|
219
|
+
} else if (elem.mozMatchesSelector !== undefined) {
|
|
220
|
+
return elem.mozMatchesSelector(selector);
|
|
221
|
+
} else {
|
|
222
|
+
throw new Error('Browser lacks native selectors');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
408
225
|
};
|
|
409
226
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
227
|
+
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
228
|
+
|
|
229
|
+
const name = element => {
|
|
230
|
+
const r = element.dom.nodeName;
|
|
231
|
+
return r.toLowerCase();
|
|
413
232
|
};
|
|
414
|
-
const type =
|
|
415
|
-
const isType =
|
|
233
|
+
const type = element => element.dom.nodeType;
|
|
234
|
+
const isType = t => element => type(element) === t;
|
|
416
235
|
const isElement = isType(ELEMENT);
|
|
417
236
|
const isText = isType(TEXT);
|
|
237
|
+
const isDocument = isType(DOCUMENT);
|
|
418
238
|
const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
419
|
-
const isTag =
|
|
239
|
+
const isTag = tag => e => isElement(e) && name(e) === tag;
|
|
420
240
|
|
|
421
|
-
const
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
* Is the element a ShadowRoot?
|
|
426
|
-
*
|
|
427
|
-
* Note: this is insufficient to test if any element is a shadow root, but it is sufficient to differentiate between
|
|
428
|
-
* a Document and a ShadowRoot.
|
|
429
|
-
*/
|
|
430
|
-
const isShadowRoot = (dos) => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
431
|
-
const getRootNode = (e) => SugarElement.fromDom(e.dom.getRootNode());
|
|
432
|
-
/** If this element is in a ShadowRoot, return it. */
|
|
433
|
-
const getShadowRoot = (e) => {
|
|
434
|
-
const r = getRootNode(e);
|
|
435
|
-
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
436
|
-
};
|
|
437
|
-
/** Return the host of a ShadowRoot.
|
|
438
|
-
*
|
|
439
|
-
* This function will throw if Shadow DOM is unsupported in the browser, or if the host is null.
|
|
440
|
-
* If you actually have a ShadowRoot, this shouldn't happen.
|
|
441
|
-
*/
|
|
442
|
-
const getShadowHost = (e) => SugarElement.fromDom(e.dom.host);
|
|
241
|
+
const owner = element => SugarElement.fromDom(element.dom.ownerDocument);
|
|
242
|
+
const documentOrOwner = dos => isDocument(dos) ? dos : owner(dos);
|
|
243
|
+
const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
244
|
+
const children$2 = element => map(element.dom.childNodes, SugarElement.fromDom);
|
|
443
245
|
|
|
444
246
|
const rawSet = (dom, key, value) => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
dom.setAttribute(key, value + '');
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
// eslint-disable-next-line no-console
|
|
455
|
-
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
456
|
-
throw new Error('Attribute value was not simple');
|
|
457
|
-
}
|
|
247
|
+
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
248
|
+
dom.setAttribute(key, value + '');
|
|
249
|
+
} else {
|
|
250
|
+
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
251
|
+
throw new Error('Attribute value was not simple');
|
|
252
|
+
}
|
|
458
253
|
};
|
|
459
254
|
const set = (element, key, value) => {
|
|
460
|
-
|
|
255
|
+
rawSet(element.dom, key, value);
|
|
461
256
|
};
|
|
462
257
|
const remove = (element, key) => {
|
|
463
|
-
|
|
258
|
+
element.dom.removeAttribute(key);
|
|
464
259
|
};
|
|
465
260
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
261
|
+
const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
262
|
+
const supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
|
263
|
+
const getRootNode = supported ? e => SugarElement.fromDom(e.dom.getRootNode()) : documentOrOwner;
|
|
264
|
+
const getShadowRoot = e => {
|
|
265
|
+
const r = getRootNode(e);
|
|
266
|
+
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
267
|
+
};
|
|
268
|
+
const getShadowHost = e => SugarElement.fromDom(e.dom.host);
|
|
471
269
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
// Normally contains is bad because an element "contains" itself, but here we want that.
|
|
480
|
-
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
481
|
-
return false;
|
|
482
|
-
}
|
|
483
|
-
const doc = dom.ownerDocument;
|
|
484
|
-
return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
|
|
270
|
+
const inBody = element => {
|
|
271
|
+
const dom = isText(element) ? element.dom.parentNode : element.dom;
|
|
272
|
+
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
const doc = dom.ownerDocument;
|
|
276
|
+
return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
|
|
485
277
|
};
|
|
486
278
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*
|
|
501
|
-
* JQuery has some magic here for IE popups, but we don't really need that.
|
|
502
|
-
* It also uses element.ownerDocument.defaultView to handle iframes but that hasn't been required since FF 3.6.
|
|
503
|
-
*/
|
|
504
|
-
const styles = window.getComputedStyle(dom);
|
|
505
|
-
const r = styles.getPropertyValue(property);
|
|
506
|
-
// jquery-ism: If r is an empty string, check that the element is not in a document. If it isn't, return the raw value.
|
|
507
|
-
// Turns out we do this a lot.
|
|
508
|
-
return (r === '' && !inBody(element)) ? getUnsafeProperty(dom, property) : r;
|
|
279
|
+
const ancestor$1 = (scope, predicate, isRoot) => {
|
|
280
|
+
let element = scope.dom;
|
|
281
|
+
const stop = isFunction(isRoot) ? isRoot : never;
|
|
282
|
+
while (element.parentNode) {
|
|
283
|
+
element = element.parentNode;
|
|
284
|
+
const el = SugarElement.fromDom(element);
|
|
285
|
+
if (predicate(el)) {
|
|
286
|
+
return Optional.some(el);
|
|
287
|
+
} else if (stop(el)) {
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return Optional.none();
|
|
509
292
|
};
|
|
510
|
-
// removed: support for dom().style[property] where prop is camel case instead of normal property name
|
|
511
|
-
// empty string is what the browsers (IE11 and Chrome) return when the propertyValue doesn't exists.
|
|
512
|
-
const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
|
|
513
293
|
|
|
514
|
-
const
|
|
294
|
+
const ancestor = (scope, selector, isRoot) => ancestor$1(scope, e => is(e, selector), isRoot);
|
|
515
295
|
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
return Optional.some(el);
|
|
524
|
-
}
|
|
525
|
-
else if (stop(el)) {
|
|
526
|
-
break;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return Optional.none();
|
|
296
|
+
const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
297
|
+
|
|
298
|
+
const get = (element, property) => {
|
|
299
|
+
const dom = element.dom;
|
|
300
|
+
const styles = window.getComputedStyle(dom);
|
|
301
|
+
const r = styles.getPropertyValue(property);
|
|
302
|
+
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
|
|
530
303
|
};
|
|
304
|
+
const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
|
|
531
305
|
|
|
532
|
-
const
|
|
306
|
+
const getDirection = element => get(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
|
|
533
307
|
|
|
534
308
|
const children$1 = (scope, predicate) => filter(children$2(scope), predicate);
|
|
535
309
|
|
|
536
|
-
const children = (scope, selector) =>
|
|
537
|
-
// It may surprise you to learn this is exactly what JQuery does
|
|
538
|
-
// TODO: Avoid all the wrapping and unwrapping
|
|
539
|
-
children$1(scope, (e) => is(e, selector));
|
|
310
|
+
const children = (scope, selector) => children$1(scope, e => is(e, selector));
|
|
540
311
|
|
|
541
|
-
const getParentElement =
|
|
542
|
-
// if the block is a list item, we need to get the parent of the list itself
|
|
312
|
+
const getParentElement = element => parent(element).filter(isElement);
|
|
543
313
|
const getNormalizedBlock = (element, isListItem) => {
|
|
544
|
-
|
|
545
|
-
|
|
314
|
+
const normalizedElement = isListItem ? ancestor(element, 'ol,ul') : Optional.some(element);
|
|
315
|
+
return normalizedElement.getOr(element);
|
|
546
316
|
};
|
|
547
317
|
const isListItem = isTag('li');
|
|
548
318
|
const setDirOnElements = (dom, blocks, dir) => {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
// Remove dir attr and direction style from list children
|
|
571
|
-
if (isBlockElementListItem) {
|
|
572
|
-
const listItems = children(normalizedBlock, 'li[dir],li[style]');
|
|
573
|
-
each(listItems, (listItem) => {
|
|
574
|
-
remove(listItem, 'dir');
|
|
575
|
-
dom.setStyle(listItem.dom, 'direction', null);
|
|
576
|
-
});
|
|
577
|
-
}
|
|
319
|
+
each(blocks, block => {
|
|
320
|
+
const blockElement = SugarElement.fromDom(block);
|
|
321
|
+
const isBlockElementListItem = isListItem(blockElement);
|
|
322
|
+
const normalizedBlock = getNormalizedBlock(blockElement, isBlockElementListItem);
|
|
323
|
+
const normalizedBlockParent = getParentElement(normalizedBlock);
|
|
324
|
+
normalizedBlockParent.each(parent => {
|
|
325
|
+
dom.setStyle(normalizedBlock.dom, 'direction', null);
|
|
326
|
+
const parentDirection = getDirection(parent);
|
|
327
|
+
if (parentDirection === dir) {
|
|
328
|
+
remove(normalizedBlock, 'dir');
|
|
329
|
+
} else {
|
|
330
|
+
set(normalizedBlock, 'dir', dir);
|
|
331
|
+
}
|
|
332
|
+
if (getDirection(normalizedBlock) !== dir) {
|
|
333
|
+
dom.setStyle(normalizedBlock.dom, 'direction', dir);
|
|
334
|
+
}
|
|
335
|
+
if (isBlockElementListItem) {
|
|
336
|
+
const listItems = children(normalizedBlock, 'li[dir],li[style]');
|
|
337
|
+
each(listItems, listItem => {
|
|
338
|
+
remove(listItem, 'dir');
|
|
339
|
+
dom.setStyle(listItem.dom, 'direction', null);
|
|
578
340
|
});
|
|
341
|
+
}
|
|
579
342
|
});
|
|
343
|
+
});
|
|
580
344
|
};
|
|
581
345
|
const setDir = (editor, dir) => {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
346
|
+
if (editor.selection.isEditable()) {
|
|
347
|
+
setDirOnElements(editor.dom, editor.selection.getSelectedBlocks(), dir);
|
|
348
|
+
editor.nodeChanged();
|
|
349
|
+
}
|
|
586
350
|
};
|
|
587
351
|
|
|
588
|
-
const register$1 =
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
352
|
+
const register$1 = editor => {
|
|
353
|
+
editor.addCommand('mceDirectionLTR', () => {
|
|
354
|
+
setDir(editor, 'ltr');
|
|
355
|
+
});
|
|
356
|
+
editor.addCommand('mceDirectionRTL', () => {
|
|
357
|
+
setDir(editor, 'rtl');
|
|
358
|
+
});
|
|
595
359
|
};
|
|
596
360
|
|
|
597
|
-
const getNodeChangeHandler = (editor, dir) =>
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
api.setEnabled(editor.selection.isEditable());
|
|
602
|
-
};
|
|
603
|
-
editor.on('NodeChange', nodeChangeHandler);
|
|
361
|
+
const getNodeChangeHandler = (editor, dir) => api => {
|
|
362
|
+
const nodeChangeHandler = e => {
|
|
363
|
+
const element = SugarElement.fromDom(e.element);
|
|
364
|
+
api.setActive(getDirection(element) === dir);
|
|
604
365
|
api.setEnabled(editor.selection.isEditable());
|
|
605
|
-
|
|
366
|
+
};
|
|
367
|
+
editor.on('NodeChange', nodeChangeHandler);
|
|
368
|
+
api.setEnabled(editor.selection.isEditable());
|
|
369
|
+
return () => editor.off('NodeChange', nodeChangeHandler);
|
|
606
370
|
};
|
|
607
|
-
const register =
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
371
|
+
const register = editor => {
|
|
372
|
+
editor.ui.registry.addToggleButton('ltr', {
|
|
373
|
+
tooltip: 'Left to right',
|
|
374
|
+
icon: 'ltr',
|
|
375
|
+
onAction: () => editor.execCommand('mceDirectionLTR'),
|
|
376
|
+
onSetup: getNodeChangeHandler(editor, 'ltr')
|
|
377
|
+
});
|
|
378
|
+
editor.ui.registry.addToggleButton('rtl', {
|
|
379
|
+
tooltip: 'Right to left',
|
|
380
|
+
icon: 'rtl',
|
|
381
|
+
onAction: () => editor.execCommand('mceDirectionRTL'),
|
|
382
|
+
onSetup: getNodeChangeHandler(editor, 'rtl')
|
|
383
|
+
});
|
|
620
384
|
};
|
|
621
385
|
|
|
622
386
|
var Plugin = () => {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
387
|
+
global.add('directionality', editor => {
|
|
388
|
+
register$1(editor);
|
|
389
|
+
register(editor);
|
|
390
|
+
});
|
|
627
391
|
};
|
|
628
392
|
|
|
629
393
|
Plugin();
|
|
630
|
-
/** *****
|
|
631
|
-
* DO NOT EXPORT ANYTHING
|
|
632
|
-
*
|
|
633
|
-
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
634
|
-
*******/
|
|
635
394
|
|
|
636
395
|
})();
|