@dangl/angular-material-shared 2.9.0-beta0040 → 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,476 +7,294 @@
|
|
|
7
7
|
|
|
8
8
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const isSimpleType = (type) => (value) => typeof value === type;
|
|
12
|
-
const eq = (t) => (a) => t === a;
|
|
10
|
+
const eq = t => a => t === a;
|
|
13
11
|
const isNull = eq(null);
|
|
14
12
|
const isUndefined = eq(undefined);
|
|
15
|
-
const isNullable =
|
|
16
|
-
const isNonNullable =
|
|
17
|
-
const isFunction = isSimpleType('function');
|
|
13
|
+
const isNullable = a => a === null || a === undefined;
|
|
14
|
+
const isNonNullable = a => !isNullable(a);
|
|
18
15
|
|
|
19
|
-
const noop = () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const noop = () => {
|
|
17
|
+
};
|
|
18
|
+
const constant = value => {
|
|
19
|
+
return () => {
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
24
22
|
};
|
|
25
23
|
const never = constant(false);
|
|
26
24
|
|
|
27
|
-
/**
|
|
28
|
-
* The `Optional` type represents a value (of any type) that potentially does
|
|
29
|
-
* not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
|
|
30
|
-
* value does exist) or a `None` (in which case the value does not exist). This
|
|
31
|
-
* module defines a whole lot of FP-inspired utility functions for dealing with
|
|
32
|
-
* `Optional` objects.
|
|
33
|
-
*
|
|
34
|
-
* Comparison with null or undefined:
|
|
35
|
-
* - We don't get fancy null coalescing operators with `Optional`
|
|
36
|
-
* - We do get fancy helper functions with `Optional`
|
|
37
|
-
* - `Optional` support nesting, and allow for the type to still be nullable (or
|
|
38
|
-
* another `Optional`)
|
|
39
|
-
* - There is no option to turn off strict-optional-checks like there is for
|
|
40
|
-
* strict-null-checks
|
|
41
|
-
*/
|
|
42
25
|
class Optional {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* any type because we don't actually have a `T`.
|
|
59
|
-
*/
|
|
60
|
-
static none() {
|
|
61
|
-
return Optional.singletonNone;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Perform a transform on an `Optional` type. Regardless of whether this
|
|
65
|
-
* `Optional` contains a value or not, `fold` will return a value of type `U`.
|
|
66
|
-
* If this `Optional` does not contain a value, the `U` will be created by
|
|
67
|
-
* calling `onNone`. If this `Optional` does contain a value, the `U` will be
|
|
68
|
-
* created by calling `onSome`.
|
|
69
|
-
*
|
|
70
|
-
* For the FP enthusiasts in the room, this function:
|
|
71
|
-
* 1. Could be used to implement all of the functions below
|
|
72
|
-
* 2. Forms a catamorphism
|
|
73
|
-
*/
|
|
74
|
-
fold(onNone, onSome) {
|
|
75
|
-
if (this.tag) {
|
|
76
|
-
return onSome(this.value);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
return onNone();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Determine if this `Optional` object contains a value.
|
|
84
|
-
*/
|
|
85
|
-
isSome() {
|
|
86
|
-
return this.tag;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Determine if this `Optional` object **does not** contain a value.
|
|
90
|
-
*/
|
|
91
|
-
isNone() {
|
|
92
|
-
return !this.tag;
|
|
93
|
-
}
|
|
94
|
-
// --- Functor (name stolen from Haskell / maths) ---
|
|
95
|
-
/**
|
|
96
|
-
* Perform a transform on an `Optional` object, **if** there is a value. If
|
|
97
|
-
* you provide a function to turn a T into a U, this is the function you use
|
|
98
|
-
* to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
|
|
99
|
-
* a value then the output will also contain a value (that value being the
|
|
100
|
-
* output of `mapper(this.value)`), and if this **does not** contain a value
|
|
101
|
-
* then neither will the output.
|
|
102
|
-
*/
|
|
103
|
-
map(mapper) {
|
|
104
|
-
if (this.tag) {
|
|
105
|
-
return Optional.some(mapper(this.value));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
return Optional.none();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// --- Monad (name stolen from Haskell / maths) ---
|
|
112
|
-
/**
|
|
113
|
-
* Perform a transform on an `Optional` object, **if** there is a value.
|
|
114
|
-
* Unlike `map`, here the transform itself also returns an `Optional`.
|
|
115
|
-
*/
|
|
116
|
-
bind(binder) {
|
|
117
|
-
if (this.tag) {
|
|
118
|
-
return binder(this.value);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return Optional.none();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// --- Traversable (name stolen from Haskell / maths) ---
|
|
125
|
-
/**
|
|
126
|
-
* For a given predicate, this function finds out if there **exists** a value
|
|
127
|
-
* inside this `Optional` object that meets the predicate. In practice, this
|
|
128
|
-
* means that for `Optional`s that do not contain a value it returns false (as
|
|
129
|
-
* no predicate-meeting value exists).
|
|
130
|
-
*/
|
|
131
|
-
exists(predicate) {
|
|
132
|
-
return this.tag && predicate(this.value);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* For a given predicate, this function finds out if **all** the values inside
|
|
136
|
-
* this `Optional` object meet the predicate. In practice, this means that
|
|
137
|
-
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
138
|
-
* objects do meet the predicate).
|
|
139
|
-
*/
|
|
140
|
-
forall(predicate) {
|
|
141
|
-
return !this.tag || predicate(this.value);
|
|
142
|
-
}
|
|
143
|
-
filter(predicate) {
|
|
144
|
-
if (!this.tag || predicate(this.value)) {
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
return Optional.none();
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
// --- Getters ---
|
|
152
|
-
/**
|
|
153
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
154
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
155
|
-
* value.
|
|
156
|
-
*/
|
|
157
|
-
getOr(replacement) {
|
|
158
|
-
return this.tag ? this.value : replacement;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
162
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
163
|
-
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
164
|
-
* `Optional` - meaning that this method will always return an `Optional`.
|
|
165
|
-
*/
|
|
166
|
-
or(replacement) {
|
|
167
|
-
return this.tag ? this : replacement;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
171
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
172
|
-
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
173
|
-
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
174
|
-
* pass a function which (if called) will **return** the `value` you want to
|
|
175
|
-
* use.
|
|
176
|
-
*/
|
|
177
|
-
getOrThunk(thunk) {
|
|
178
|
-
return this.tag ? this.value : thunk();
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
182
|
-
* `replacement` value if the provided Optional object does not contain a
|
|
183
|
-
* value.
|
|
184
|
-
*
|
|
185
|
-
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
186
|
-
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
187
|
-
* (if called) will **return** the `value` you want to use.
|
|
188
|
-
*
|
|
189
|
-
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
190
|
-
* `Optional`, meaning that this method will always return an `Optional`.
|
|
191
|
-
*/
|
|
192
|
-
orThunk(thunk) {
|
|
193
|
-
return this.tag ? this : thunk();
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Get the value out of the inside of the `Optional` object, throwing an
|
|
197
|
-
* exception if the provided `Optional` object does not contain a value.
|
|
198
|
-
*
|
|
199
|
-
* WARNING:
|
|
200
|
-
* You should only be using this function if you know that the `Optional`
|
|
201
|
-
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
202
|
-
* code, which is bad).
|
|
203
|
-
*
|
|
204
|
-
* In tests this is more acceptable.
|
|
205
|
-
*
|
|
206
|
-
* Prefer other methods to this, such as `.each`.
|
|
207
|
-
*/
|
|
208
|
-
getOrDie(message) {
|
|
209
|
-
if (!this.tag) {
|
|
210
|
-
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
return this.value;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
// --- Interop with null and undefined ---
|
|
217
|
-
/**
|
|
218
|
-
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
219
|
-
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
220
|
-
* to `Some`.
|
|
221
|
-
*/
|
|
222
|
-
static from(value) {
|
|
223
|
-
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
26
|
+
constructor(tag, value) {
|
|
27
|
+
this.tag = tag;
|
|
28
|
+
this.value = value;
|
|
29
|
+
}
|
|
30
|
+
static some(value) {
|
|
31
|
+
return new Optional(true, value);
|
|
32
|
+
}
|
|
33
|
+
static none() {
|
|
34
|
+
return Optional.singletonNone;
|
|
35
|
+
}
|
|
36
|
+
fold(onNone, onSome) {
|
|
37
|
+
if (this.tag) {
|
|
38
|
+
return onSome(this.value);
|
|
39
|
+
} else {
|
|
40
|
+
return onNone();
|
|
224
41
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
42
|
+
}
|
|
43
|
+
isSome() {
|
|
44
|
+
return this.tag;
|
|
45
|
+
}
|
|
46
|
+
isNone() {
|
|
47
|
+
return !this.tag;
|
|
48
|
+
}
|
|
49
|
+
map(mapper) {
|
|
50
|
+
if (this.tag) {
|
|
51
|
+
return Optional.some(mapper(this.value));
|
|
52
|
+
} else {
|
|
53
|
+
return Optional.none();
|
|
231
54
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
55
|
+
}
|
|
56
|
+
bind(binder) {
|
|
57
|
+
if (this.tag) {
|
|
58
|
+
return binder(this.value);
|
|
59
|
+
} else {
|
|
60
|
+
return Optional.none();
|
|
238
61
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
each(worker) {
|
|
252
|
-
if (this.tag) {
|
|
253
|
-
worker(this.value);
|
|
254
|
-
}
|
|
62
|
+
}
|
|
63
|
+
exists(predicate) {
|
|
64
|
+
return this.tag && predicate(this.value);
|
|
65
|
+
}
|
|
66
|
+
forall(predicate) {
|
|
67
|
+
return !this.tag || predicate(this.value);
|
|
68
|
+
}
|
|
69
|
+
filter(predicate) {
|
|
70
|
+
if (!this.tag || predicate(this.value)) {
|
|
71
|
+
return this;
|
|
72
|
+
} else {
|
|
73
|
+
return Optional.none();
|
|
255
74
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
75
|
+
}
|
|
76
|
+
getOr(replacement) {
|
|
77
|
+
return this.tag ? this.value : replacement;
|
|
78
|
+
}
|
|
79
|
+
or(replacement) {
|
|
80
|
+
return this.tag ? this : replacement;
|
|
81
|
+
}
|
|
82
|
+
getOrThunk(thunk) {
|
|
83
|
+
return this.tag ? this.value : thunk();
|
|
84
|
+
}
|
|
85
|
+
orThunk(thunk) {
|
|
86
|
+
return this.tag ? this : thunk();
|
|
87
|
+
}
|
|
88
|
+
getOrDie(message) {
|
|
89
|
+
if (!this.tag) {
|
|
90
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
91
|
+
} else {
|
|
92
|
+
return this.value;
|
|
263
93
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
94
|
+
}
|
|
95
|
+
static from(value) {
|
|
96
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
97
|
+
}
|
|
98
|
+
getOrNull() {
|
|
99
|
+
return this.tag ? this.value : null;
|
|
100
|
+
}
|
|
101
|
+
getOrUndefined() {
|
|
102
|
+
return this.value;
|
|
103
|
+
}
|
|
104
|
+
each(worker) {
|
|
105
|
+
if (this.tag) {
|
|
106
|
+
worker(this.value);
|
|
272
107
|
}
|
|
108
|
+
}
|
|
109
|
+
toArray() {
|
|
110
|
+
return this.tag ? [this.value] : [];
|
|
111
|
+
}
|
|
112
|
+
toString() {
|
|
113
|
+
return this.tag ? `some(${ this.value })` : 'none()';
|
|
114
|
+
}
|
|
273
115
|
}
|
|
274
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
275
|
-
// reuse the same object
|
|
276
116
|
Optional.singletonNone = new Optional(false);
|
|
277
117
|
|
|
278
|
-
/* eslint-disable @typescript-eslint/unbound-method */
|
|
279
|
-
const nativeSlice = Array.prototype.slice;
|
|
280
118
|
const exists = (xs, pred) => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
119
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
120
|
+
const x = xs[i];
|
|
121
|
+
if (pred(x, i)) {
|
|
122
|
+
return true;
|
|
286
123
|
}
|
|
287
|
-
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
288
126
|
};
|
|
289
127
|
const map$1 = (xs, f) => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
return r;
|
|
128
|
+
const len = xs.length;
|
|
129
|
+
const r = new Array(len);
|
|
130
|
+
for (let i = 0; i < len; i++) {
|
|
131
|
+
const x = xs[i];
|
|
132
|
+
r[i] = f(x, i);
|
|
133
|
+
}
|
|
134
|
+
return r;
|
|
299
135
|
};
|
|
300
|
-
// Unwound implementing other functions in terms of each.
|
|
301
|
-
// The code size is roughly the same, and it should allow for better optimisation.
|
|
302
|
-
// const each = function<T, U>(xs: T[], f: (x: T, i?: number, xs?: T[]) => void): void {
|
|
303
136
|
const each$1 = (xs, f) => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
137
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
138
|
+
const x = xs[i];
|
|
139
|
+
f(x, i);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const Cell = initial => {
|
|
144
|
+
let value = initial;
|
|
145
|
+
const get = () => {
|
|
146
|
+
return value;
|
|
147
|
+
};
|
|
148
|
+
const set = v => {
|
|
149
|
+
value = v;
|
|
150
|
+
};
|
|
151
|
+
return {
|
|
152
|
+
get,
|
|
153
|
+
set
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const last = (fn, rate) => {
|
|
158
|
+
let timer = null;
|
|
159
|
+
const cancel = () => {
|
|
160
|
+
if (!isNull(timer)) {
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
timer = null;
|
|
307
163
|
}
|
|
164
|
+
};
|
|
165
|
+
const throttle = (...args) => {
|
|
166
|
+
cancel();
|
|
167
|
+
timer = setTimeout(() => {
|
|
168
|
+
timer = null;
|
|
169
|
+
fn.apply(null, args);
|
|
170
|
+
}, rate);
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
cancel,
|
|
174
|
+
throttle
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const insertEmoticon = (editor, ch) => {
|
|
179
|
+
editor.insertContent(ch);
|
|
308
180
|
};
|
|
309
|
-
isFunction(Array.from) ? Array.from : (x) => nativeSlice.call(x);
|
|
310
181
|
|
|
311
|
-
// There are many variations of Object iteration that are faster than the 'for-in' style:
|
|
312
|
-
// http://jsperf.com/object-keys-iteration/107
|
|
313
|
-
//
|
|
314
|
-
// Use the native keys if it is available (IE9+), otherwise fall back to manually filtering
|
|
315
182
|
const keys = Object.keys;
|
|
316
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
317
183
|
const hasOwnProperty = Object.hasOwnProperty;
|
|
318
184
|
const each = (obj, f) => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
185
|
+
const props = keys(obj);
|
|
186
|
+
for (let k = 0, len = props.length; k < len; k++) {
|
|
187
|
+
const i = props[k];
|
|
188
|
+
const x = obj[i];
|
|
189
|
+
f(x, i);
|
|
190
|
+
}
|
|
325
191
|
};
|
|
326
192
|
const map = (obj, f) => {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
193
|
+
return tupleMap(obj, (x, i) => ({
|
|
194
|
+
k: i,
|
|
195
|
+
v: f(x, i)
|
|
196
|
+
}));
|
|
331
197
|
};
|
|
332
198
|
const tupleMap = (obj, f) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
199
|
+
const r = {};
|
|
200
|
+
each(obj, (x, i) => {
|
|
201
|
+
const tuple = f(x, i);
|
|
202
|
+
r[tuple.k] = tuple.v;
|
|
203
|
+
});
|
|
204
|
+
return r;
|
|
339
205
|
};
|
|
340
206
|
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
|
341
207
|
|
|
342
|
-
const Cell = (initial) => {
|
|
343
|
-
let value = initial;
|
|
344
|
-
const get = () => {
|
|
345
|
-
return value;
|
|
346
|
-
};
|
|
347
|
-
const set = (v) => {
|
|
348
|
-
value = v;
|
|
349
|
-
};
|
|
350
|
-
return {
|
|
351
|
-
get,
|
|
352
|
-
set
|
|
353
|
-
};
|
|
354
|
-
};
|
|
355
|
-
|
|
356
208
|
const shallow = (old, nu) => {
|
|
357
|
-
|
|
209
|
+
return nu;
|
|
358
210
|
};
|
|
359
|
-
const baseMerge =
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
}
|
|
211
|
+
const baseMerge = merger => {
|
|
212
|
+
return (...objects) => {
|
|
213
|
+
if (objects.length === 0) {
|
|
214
|
+
throw new Error(`Can't merge zero objects`);
|
|
215
|
+
}
|
|
216
|
+
const ret = {};
|
|
217
|
+
for (let j = 0; j < objects.length; j++) {
|
|
218
|
+
const curObject = objects[j];
|
|
219
|
+
for (const key in curObject) {
|
|
220
|
+
if (has(curObject, key)) {
|
|
221
|
+
ret[key] = merger(ret[key], curObject[key]);
|
|
372
222
|
}
|
|
373
|
-
|
|
374
|
-
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return ret;
|
|
226
|
+
};
|
|
375
227
|
};
|
|
376
228
|
const merge = baseMerge(shallow);
|
|
377
229
|
|
|
378
|
-
const singleton =
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
230
|
+
const singleton = doRevoke => {
|
|
231
|
+
const subject = Cell(Optional.none());
|
|
232
|
+
const revoke = () => subject.get().each(doRevoke);
|
|
233
|
+
const clear = () => {
|
|
234
|
+
revoke();
|
|
235
|
+
subject.set(Optional.none());
|
|
236
|
+
};
|
|
237
|
+
const isSet = () => subject.get().isSome();
|
|
238
|
+
const get = () => subject.get();
|
|
239
|
+
const set = s => {
|
|
240
|
+
revoke();
|
|
241
|
+
subject.set(Optional.some(s));
|
|
242
|
+
};
|
|
243
|
+
return {
|
|
244
|
+
clear,
|
|
245
|
+
isSet,
|
|
246
|
+
get,
|
|
247
|
+
set
|
|
248
|
+
};
|
|
397
249
|
};
|
|
398
250
|
const value = () => {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
251
|
+
const subject = singleton(noop);
|
|
252
|
+
const on = f => subject.get().each(f);
|
|
253
|
+
return {
|
|
254
|
+
...subject,
|
|
255
|
+
on
|
|
256
|
+
};
|
|
405
257
|
};
|
|
406
258
|
|
|
407
259
|
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
408
260
|
const contains = (str, substr, start = 0, end) => {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
261
|
+
const idx = str.indexOf(substr, start);
|
|
262
|
+
if (idx !== -1) {
|
|
263
|
+
return isUndefined(end) ? true : idx + substr.length <= end;
|
|
264
|
+
} else {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
416
267
|
};
|
|
417
|
-
/** Does 'str' start with 'prefix'?
|
|
418
|
-
* Note: all strings start with the empty string.
|
|
419
|
-
* More formally, for all strings x, startsWith(x, "").
|
|
420
|
-
* This is so that for all strings x and y, startsWith(y + x, y)
|
|
421
|
-
*/
|
|
422
268
|
const startsWith = (str, prefix) => {
|
|
423
|
-
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
// Run a function fn after rate ms. If another invocation occurs
|
|
427
|
-
// during the time it is waiting, reschedule the function again
|
|
428
|
-
// with the new arguments.
|
|
429
|
-
const last = (fn, rate) => {
|
|
430
|
-
let timer = null;
|
|
431
|
-
const cancel = () => {
|
|
432
|
-
if (!isNull(timer)) {
|
|
433
|
-
clearTimeout(timer);
|
|
434
|
-
timer = null;
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
const throttle = (...args) => {
|
|
438
|
-
cancel();
|
|
439
|
-
timer = setTimeout(() => {
|
|
440
|
-
timer = null;
|
|
441
|
-
fn.apply(null, args);
|
|
442
|
-
}, rate);
|
|
443
|
-
};
|
|
444
|
-
return {
|
|
445
|
-
cancel,
|
|
446
|
-
throttle
|
|
447
|
-
};
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
const insertEmoticon = (editor, ch) => {
|
|
451
|
-
editor.insertContent(ch);
|
|
269
|
+
return checkRange(str, prefix, 0);
|
|
452
270
|
};
|
|
453
271
|
|
|
454
272
|
var global = tinymce.util.Tools.resolve('tinymce.Resource');
|
|
455
273
|
|
|
456
274
|
const DEFAULT_ID = 'tinymce.plugins.emoticons';
|
|
457
|
-
const option =
|
|
275
|
+
const option = name => editor => editor.options.get(name);
|
|
458
276
|
const register$2 = (editor, pluginUrl) => {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
277
|
+
const registerOption = editor.options.register;
|
|
278
|
+
registerOption('emoticons_database', {
|
|
279
|
+
processor: 'string',
|
|
280
|
+
default: 'emojis'
|
|
281
|
+
});
|
|
282
|
+
registerOption('emoticons_database_url', {
|
|
283
|
+
processor: 'string',
|
|
284
|
+
default: `${ pluginUrl }/js/${ getEmojiDatabase(editor) }${ editor.suffix }.js`
|
|
285
|
+
});
|
|
286
|
+
registerOption('emoticons_database_id', {
|
|
287
|
+
processor: 'string',
|
|
288
|
+
default: DEFAULT_ID
|
|
289
|
+
});
|
|
290
|
+
registerOption('emoticons_append', {
|
|
291
|
+
processor: 'object',
|
|
292
|
+
default: {}
|
|
293
|
+
});
|
|
294
|
+
registerOption('emoticons_images_url', {
|
|
295
|
+
processor: 'string',
|
|
296
|
+
default: 'https://twemoji.maxcdn.com/v/13.0.1/72x72/'
|
|
297
|
+
});
|
|
480
298
|
};
|
|
481
299
|
const getEmojiDatabase = option('emoticons_database');
|
|
482
300
|
const getEmojiDatabaseUrl = option('emoticons_database_url');
|
|
@@ -486,324 +304,292 @@
|
|
|
486
304
|
|
|
487
305
|
const ALL_CATEGORY = 'All';
|
|
488
306
|
const categoryNameMap = {
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
307
|
+
symbols: 'Symbols',
|
|
308
|
+
people: 'People',
|
|
309
|
+
animals_and_nature: 'Animals and Nature',
|
|
310
|
+
food_and_drink: 'Food and Drink',
|
|
311
|
+
activity: 'Activity',
|
|
312
|
+
travel_and_places: 'Travel and Places',
|
|
313
|
+
objects: 'Objects',
|
|
314
|
+
flags: 'Flags',
|
|
315
|
+
user: 'User Defined'
|
|
498
316
|
};
|
|
499
317
|
const translateCategory = (categories, name) => has(categories, name) ? categories[name] : name;
|
|
500
|
-
const getUserDefinedEmoji =
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
318
|
+
const getUserDefinedEmoji = editor => {
|
|
319
|
+
const userDefinedEmoticons = getAppendedEmoji(editor);
|
|
320
|
+
return map(userDefinedEmoticons, value => ({
|
|
321
|
+
keywords: [],
|
|
322
|
+
category: 'user',
|
|
323
|
+
...value
|
|
324
|
+
}));
|
|
505
325
|
};
|
|
506
|
-
// TODO: Consider how to share this loading across different editors
|
|
507
326
|
const initDatabase = (editor, databaseUrl, databaseId) => {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
};
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const current = cats[entry.category] !== undefined ? cats[entry.category] : [];
|
|
532
|
-
cats[entry.category] = current.concat([entry]);
|
|
533
|
-
everything.push(entry);
|
|
534
|
-
});
|
|
535
|
-
categories.set(cats);
|
|
536
|
-
all.set(everything);
|
|
537
|
-
};
|
|
538
|
-
editor.on('init', () => {
|
|
539
|
-
global.load(databaseId, databaseUrl).then((emojis) => {
|
|
540
|
-
const userEmojis = getUserDefinedEmoji(editor);
|
|
541
|
-
processEmojis(merge(emojis, userEmojis));
|
|
542
|
-
}, (err) => {
|
|
543
|
-
// eslint-disable-next-line no-console
|
|
544
|
-
console.log(`Failed to load emojis: ${err}`);
|
|
545
|
-
categories.set({});
|
|
546
|
-
all.set([]);
|
|
547
|
-
});
|
|
327
|
+
const categories = value();
|
|
328
|
+
const all = value();
|
|
329
|
+
const emojiImagesUrl = getEmojiImageUrl(editor);
|
|
330
|
+
const getEmoji = lib => {
|
|
331
|
+
if (startsWith(lib.char, '<img')) {
|
|
332
|
+
return lib.char.replace(/src="([^"]+)"/, (match, url) => `src="${ emojiImagesUrl }${ url }"`);
|
|
333
|
+
} else {
|
|
334
|
+
return lib.char;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const processEmojis = emojis => {
|
|
338
|
+
const cats = {};
|
|
339
|
+
const everything = [];
|
|
340
|
+
each(emojis, (lib, title) => {
|
|
341
|
+
const entry = {
|
|
342
|
+
title,
|
|
343
|
+
keywords: lib.keywords,
|
|
344
|
+
char: getEmoji(lib),
|
|
345
|
+
category: translateCategory(categoryNameMap, lib.category)
|
|
346
|
+
};
|
|
347
|
+
const current = cats[entry.category] !== undefined ? cats[entry.category] : [];
|
|
348
|
+
cats[entry.category] = current.concat([entry]);
|
|
349
|
+
everything.push(entry);
|
|
548
350
|
});
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
351
|
+
categories.set(cats);
|
|
352
|
+
all.set(everything);
|
|
353
|
+
};
|
|
354
|
+
editor.on('init', () => {
|
|
355
|
+
global.load(databaseId, databaseUrl).then(emojis => {
|
|
356
|
+
const userEmojis = getUserDefinedEmoji(editor);
|
|
357
|
+
processEmojis(merge(emojis, userEmojis));
|
|
358
|
+
}, err => {
|
|
359
|
+
console.log(`Failed to load emojis: ${ err }`);
|
|
360
|
+
categories.set({});
|
|
361
|
+
all.set([]);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
const listCategory = category => {
|
|
365
|
+
if (category === ALL_CATEGORY) {
|
|
366
|
+
return listAll();
|
|
367
|
+
}
|
|
368
|
+
return categories.get().bind(cats => Optional.from(cats[category])).getOr([]);
|
|
369
|
+
};
|
|
370
|
+
const listAll = () => all.get().getOr([]);
|
|
371
|
+
const listCategories = () => [ALL_CATEGORY].concat(keys(categories.get().getOr({})));
|
|
372
|
+
const waitForLoad = () => {
|
|
373
|
+
if (hasLoaded()) {
|
|
374
|
+
return Promise.resolve(true);
|
|
375
|
+
} else {
|
|
376
|
+
return new Promise((resolve, reject) => {
|
|
377
|
+
let numRetries = 15;
|
|
378
|
+
const interval = setInterval(() => {
|
|
379
|
+
if (hasLoaded()) {
|
|
380
|
+
clearInterval(interval);
|
|
381
|
+
resolve(true);
|
|
382
|
+
} else {
|
|
383
|
+
numRetries--;
|
|
384
|
+
if (numRetries < 0) {
|
|
385
|
+
console.log('Could not load emojis from url: ' + databaseUrl);
|
|
386
|
+
clearInterval(interval);
|
|
387
|
+
reject(false);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}, 100);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
const hasLoaded = () => categories.isSet() && all.isSet();
|
|
395
|
+
return {
|
|
396
|
+
listCategories,
|
|
397
|
+
hasLoaded,
|
|
398
|
+
waitForLoad,
|
|
399
|
+
listAll,
|
|
400
|
+
listCategory
|
|
401
|
+
};
|
|
592
402
|
};
|
|
593
403
|
|
|
594
|
-
const emojiMatches = (emoji, lowerCasePattern) => contains(emoji.title.toLowerCase(), lowerCasePattern) ||
|
|
595
|
-
exists(emoji.keywords, (k) => contains(k.toLowerCase(), lowerCasePattern));
|
|
404
|
+
const emojiMatches = (emoji, lowerCasePattern) => contains(emoji.title.toLowerCase(), lowerCasePattern) || exists(emoji.keywords, k => contains(k.toLowerCase(), lowerCasePattern));
|
|
596
405
|
const emojisFrom = (list, pattern, maxResults) => {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
}
|
|
406
|
+
const matches = [];
|
|
407
|
+
const lowerCasePattern = pattern.toLowerCase();
|
|
408
|
+
const reachedLimit = maxResults.fold(() => never, max => size => size >= max);
|
|
409
|
+
for (let i = 0; i < list.length; i++) {
|
|
410
|
+
if (pattern.length === 0 || emojiMatches(list[i], lowerCasePattern)) {
|
|
411
|
+
matches.push({
|
|
412
|
+
value: list[i].char,
|
|
413
|
+
text: list[i].title,
|
|
414
|
+
icon: list[i].char
|
|
415
|
+
});
|
|
416
|
+
if (reachedLimit(matches.length)) {
|
|
417
|
+
break;
|
|
418
|
+
}
|
|
612
419
|
}
|
|
613
|
-
|
|
420
|
+
}
|
|
421
|
+
return matches;
|
|
614
422
|
};
|
|
615
423
|
|
|
616
424
|
const patternName = 'pattern';
|
|
617
425
|
const open = (editor, database) => {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
426
|
+
const initialState = {
|
|
427
|
+
pattern: '',
|
|
428
|
+
results: emojisFrom(database.listAll(), '', Optional.some(300))
|
|
429
|
+
};
|
|
430
|
+
const currentTab = Cell(ALL_CATEGORY);
|
|
431
|
+
const scan = dialogApi => {
|
|
432
|
+
const dialogData = dialogApi.getData();
|
|
433
|
+
const category = currentTab.get();
|
|
434
|
+
const candidates = database.listCategory(category);
|
|
435
|
+
const results = emojisFrom(candidates, dialogData[patternName], category === ALL_CATEGORY ? Optional.some(300) : Optional.none());
|
|
436
|
+
dialogApi.setData({ results });
|
|
437
|
+
};
|
|
438
|
+
const updateFilter = last(dialogApi => {
|
|
439
|
+
scan(dialogApi);
|
|
440
|
+
}, 200);
|
|
441
|
+
const searchField = {
|
|
442
|
+
label: 'Search',
|
|
443
|
+
type: 'input',
|
|
444
|
+
name: patternName
|
|
445
|
+
};
|
|
446
|
+
const resultsField = {
|
|
447
|
+
type: 'collection',
|
|
448
|
+
name: 'results'
|
|
449
|
+
};
|
|
450
|
+
const getInitialState = () => {
|
|
451
|
+
const body = {
|
|
452
|
+
type: 'tabpanel',
|
|
453
|
+
tabs: map$1(database.listCategories(), cat => ({
|
|
454
|
+
title: cat,
|
|
455
|
+
name: cat,
|
|
456
|
+
items: [
|
|
457
|
+
searchField,
|
|
458
|
+
resultsField
|
|
459
|
+
]
|
|
460
|
+
}))
|
|
639
461
|
};
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
onTabChange: (dialogApi, details) => {
|
|
662
|
-
currentTab.set(details.newTabName);
|
|
663
|
-
updateFilter.throttle(dialogApi);
|
|
664
|
-
},
|
|
665
|
-
onChange: updateFilter.throttle,
|
|
666
|
-
onAction: (dialogApi, actionData) => {
|
|
667
|
-
if (actionData.name === 'results') {
|
|
668
|
-
insertEmoticon(editor, actionData.value);
|
|
669
|
-
dialogApi.close();
|
|
670
|
-
}
|
|
671
|
-
},
|
|
672
|
-
buttons: [
|
|
673
|
-
{
|
|
674
|
-
type: 'cancel',
|
|
675
|
-
text: 'Close',
|
|
676
|
-
primary: true
|
|
677
|
-
}
|
|
678
|
-
]
|
|
679
|
-
};
|
|
462
|
+
return {
|
|
463
|
+
title: 'Emojis',
|
|
464
|
+
size: 'normal',
|
|
465
|
+
body,
|
|
466
|
+
initialData: initialState,
|
|
467
|
+
onTabChange: (dialogApi, details) => {
|
|
468
|
+
currentTab.set(details.newTabName);
|
|
469
|
+
updateFilter.throttle(dialogApi);
|
|
470
|
+
},
|
|
471
|
+
onChange: updateFilter.throttle,
|
|
472
|
+
onAction: (dialogApi, actionData) => {
|
|
473
|
+
if (actionData.name === 'results') {
|
|
474
|
+
insertEmoticon(editor, actionData.value);
|
|
475
|
+
dialogApi.close();
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
buttons: [{
|
|
479
|
+
type: 'cancel',
|
|
480
|
+
text: 'Close',
|
|
481
|
+
primary: true
|
|
482
|
+
}]
|
|
680
483
|
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
dialogApi.unblock();
|
|
718
|
-
});
|
|
719
|
-
}
|
|
484
|
+
};
|
|
485
|
+
const dialogApi = editor.windowManager.open(getInitialState());
|
|
486
|
+
dialogApi.focus(patternName);
|
|
487
|
+
if (!database.hasLoaded()) {
|
|
488
|
+
dialogApi.block('Loading emojis...');
|
|
489
|
+
database.waitForLoad().then(() => {
|
|
490
|
+
dialogApi.redial(getInitialState());
|
|
491
|
+
updateFilter.throttle(dialogApi);
|
|
492
|
+
dialogApi.focus(patternName);
|
|
493
|
+
dialogApi.unblock();
|
|
494
|
+
}).catch(_err => {
|
|
495
|
+
dialogApi.redial({
|
|
496
|
+
title: 'Emojis',
|
|
497
|
+
body: {
|
|
498
|
+
type: 'panel',
|
|
499
|
+
items: [{
|
|
500
|
+
type: 'alertbanner',
|
|
501
|
+
level: 'error',
|
|
502
|
+
icon: 'warning',
|
|
503
|
+
text: 'Could not load emojis'
|
|
504
|
+
}]
|
|
505
|
+
},
|
|
506
|
+
buttons: [{
|
|
507
|
+
type: 'cancel',
|
|
508
|
+
text: 'Close',
|
|
509
|
+
primary: true
|
|
510
|
+
}],
|
|
511
|
+
initialData: {
|
|
512
|
+
pattern: '',
|
|
513
|
+
results: []
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
dialogApi.focus(patternName);
|
|
517
|
+
dialogApi.unblock();
|
|
518
|
+
});
|
|
519
|
+
}
|
|
720
520
|
};
|
|
721
521
|
|
|
722
522
|
const register$1 = (editor, database) => {
|
|
723
|
-
|
|
523
|
+
editor.addCommand('mceEmoticons', () => open(editor, database));
|
|
724
524
|
};
|
|
725
525
|
|
|
726
|
-
const setup =
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
});
|
|
526
|
+
const setup = editor => {
|
|
527
|
+
editor.on('PreInit', () => {
|
|
528
|
+
editor.parser.addAttributeFilter('data-emoticon', nodes => {
|
|
529
|
+
each$1(nodes, node => {
|
|
530
|
+
node.attr('data-mce-resize', 'false');
|
|
531
|
+
node.attr('data-mce-placeholder', '1');
|
|
532
|
+
});
|
|
734
533
|
});
|
|
534
|
+
});
|
|
735
535
|
};
|
|
736
536
|
|
|
737
537
|
const init = (editor, database) => {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
538
|
+
editor.ui.registry.addAutocompleter('emoticons', {
|
|
539
|
+
trigger: ':',
|
|
540
|
+
columns: 'auto',
|
|
541
|
+
minChars: 2,
|
|
542
|
+
fetch: (pattern, maxResults) => database.waitForLoad().then(() => {
|
|
543
|
+
const candidates = database.listAll();
|
|
544
|
+
return emojisFrom(candidates, pattern, Optional.some(maxResults));
|
|
545
|
+
}),
|
|
546
|
+
onAction: (autocompleteApi, rng, value) => {
|
|
547
|
+
editor.selection.setRng(rng);
|
|
548
|
+
editor.insertContent(value);
|
|
549
|
+
autocompleteApi.hide();
|
|
550
|
+
}
|
|
551
|
+
});
|
|
752
552
|
};
|
|
753
553
|
|
|
754
|
-
const onSetupEditable =
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
554
|
+
const onSetupEditable = editor => api => {
|
|
555
|
+
const nodeChanged = () => {
|
|
556
|
+
api.setEnabled(editor.selection.isEditable());
|
|
557
|
+
};
|
|
558
|
+
editor.on('NodeChange', nodeChanged);
|
|
559
|
+
nodeChanged();
|
|
560
|
+
return () => {
|
|
561
|
+
editor.off('NodeChange', nodeChanged);
|
|
562
|
+
};
|
|
763
563
|
};
|
|
764
|
-
const register =
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
564
|
+
const register = editor => {
|
|
565
|
+
const onAction = () => editor.execCommand('mceEmoticons');
|
|
566
|
+
editor.ui.registry.addButton('emoticons', {
|
|
567
|
+
tooltip: 'Emojis',
|
|
568
|
+
icon: 'emoji',
|
|
569
|
+
onAction,
|
|
570
|
+
onSetup: onSetupEditable(editor)
|
|
571
|
+
});
|
|
572
|
+
editor.ui.registry.addMenuItem('emoticons', {
|
|
573
|
+
text: 'Emojis...',
|
|
574
|
+
icon: 'emoji',
|
|
575
|
+
onAction,
|
|
576
|
+
onSetup: onSetupEditable(editor)
|
|
577
|
+
});
|
|
778
578
|
};
|
|
779
579
|
|
|
780
|
-
/**
|
|
781
|
-
* This class contains all core logic for the emoticons plugin.
|
|
782
|
-
*
|
|
783
|
-
* @class tinymce.emoticons.Plugin
|
|
784
|
-
* @private
|
|
785
|
-
*/
|
|
786
580
|
var Plugin = () => {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
getAllEmojis: () => database.waitForLoad().then(() => database.listAll())
|
|
798
|
-
};
|
|
799
|
-
});
|
|
581
|
+
global$1.add('emoticons', (editor, pluginUrl) => {
|
|
582
|
+
register$2(editor, pluginUrl);
|
|
583
|
+
const databaseUrl = getEmojiDatabaseUrl(editor);
|
|
584
|
+
const databaseId = getEmojiDatabaseId(editor);
|
|
585
|
+
const database = initDatabase(editor, databaseUrl, databaseId);
|
|
586
|
+
register$1(editor, database);
|
|
587
|
+
register(editor);
|
|
588
|
+
init(editor, database);
|
|
589
|
+
setup(editor);
|
|
590
|
+
});
|
|
800
591
|
};
|
|
801
592
|
|
|
802
593
|
Plugin();
|
|
803
|
-
/** *****
|
|
804
|
-
* DO NOT EXPORT ANYTHING
|
|
805
|
-
*
|
|
806
|
-
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
807
|
-
*******/
|
|
808
594
|
|
|
809
595
|
})();
|