@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,648 +7,441 @@
|
|
|
7
7
|
|
|
8
8
|
var global$1 = 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 =
|
|
37
|
-
const isSimpleType =
|
|
30
|
+
const isType = type => value => typeOf(value) === type;
|
|
31
|
+
const isSimpleType = type => value => typeof value === type;
|
|
38
32
|
const isString = isType('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
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
38
|
+
const option = name => editor => editor.options.get(name);
|
|
39
|
+
const register = editor => {
|
|
40
|
+
const registerOption = editor.options.register;
|
|
41
|
+
const toolbarProcessor = defaultValue => value => {
|
|
42
|
+
const valid = isBoolean(value) || isString(value);
|
|
43
|
+
if (valid) {
|
|
44
|
+
if (isBoolean(value)) {
|
|
45
|
+
return {
|
|
46
|
+
value: value ? defaultValue : '',
|
|
47
|
+
valid
|
|
48
|
+
};
|
|
49
|
+
} else {
|
|
50
|
+
return {
|
|
51
|
+
value: value.trim(),
|
|
52
|
+
valid
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
return {
|
|
57
|
+
valid: false,
|
|
58
|
+
message: 'Must be a boolean or string.'
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const defaultSelectionToolbar = 'bold italic | quicklink h2 h3 blockquote';
|
|
63
|
+
registerOption('quickbars_selection_toolbar', {
|
|
64
|
+
processor: toolbarProcessor(defaultSelectionToolbar),
|
|
65
|
+
default: defaultSelectionToolbar
|
|
66
|
+
});
|
|
67
|
+
const defaultInsertToolbar = 'quickimage quicktable';
|
|
68
|
+
registerOption('quickbars_insert_toolbar', {
|
|
69
|
+
processor: toolbarProcessor(defaultInsertToolbar),
|
|
70
|
+
default: defaultInsertToolbar
|
|
71
|
+
});
|
|
72
|
+
const defaultImageToolbar = 'alignleft aligncenter alignright';
|
|
73
|
+
registerOption('quickbars_image_toolbar', {
|
|
74
|
+
processor: toolbarProcessor(defaultImageToolbar),
|
|
75
|
+
default: defaultImageToolbar
|
|
76
|
+
});
|
|
48
77
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* The `Optional` type represents a value (of any type) that potentially does
|
|
53
|
-
* not exist. Any `Optional<T>` can either be a `Some<T>` (in which case the
|
|
54
|
-
* value does exist) or a `None` (in which case the value does not exist). This
|
|
55
|
-
* module defines a whole lot of FP-inspired utility functions for dealing with
|
|
56
|
-
* `Optional` objects.
|
|
57
|
-
*
|
|
58
|
-
* Comparison with null or undefined:
|
|
59
|
-
* - We don't get fancy null coalescing operators with `Optional`
|
|
60
|
-
* - We do get fancy helper functions with `Optional`
|
|
61
|
-
* - `Optional` support nesting, and allow for the type to still be nullable (or
|
|
62
|
-
* another `Optional`)
|
|
63
|
-
* - There is no option to turn off strict-optional-checks like there is for
|
|
64
|
-
* strict-null-checks
|
|
65
|
-
*/
|
|
66
|
-
class Optional {
|
|
67
|
-
// The internal representation has a `tag` and a `value`, but both are
|
|
68
|
-
// private: able to be console.logged, but not able to be accessed by code
|
|
69
|
-
constructor(tag, value) {
|
|
70
|
-
this.tag = tag;
|
|
71
|
-
this.value = value;
|
|
72
|
-
}
|
|
73
|
-
// --- Identities ---
|
|
74
|
-
/**
|
|
75
|
-
* Creates a new `Optional<T>` that **does** contain a value.
|
|
76
|
-
*/
|
|
77
|
-
static some(value) {
|
|
78
|
-
return new Optional(true, value);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Create a new `Optional<T>` that **does not** contain a value. `T` can be
|
|
82
|
-
* any type because we don't actually have a `T`.
|
|
83
|
-
*/
|
|
84
|
-
static none() {
|
|
85
|
-
return Optional.singletonNone;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Perform a transform on an `Optional` type. Regardless of whether this
|
|
89
|
-
* `Optional` contains a value or not, `fold` will return a value of type `U`.
|
|
90
|
-
* If this `Optional` does not contain a value, the `U` will be created by
|
|
91
|
-
* calling `onNone`. If this `Optional` does contain a value, the `U` will be
|
|
92
|
-
* created by calling `onSome`.
|
|
93
|
-
*
|
|
94
|
-
* For the FP enthusiasts in the room, this function:
|
|
95
|
-
* 1. Could be used to implement all of the functions below
|
|
96
|
-
* 2. Forms a catamorphism
|
|
97
|
-
*/
|
|
98
|
-
fold(onNone, onSome) {
|
|
99
|
-
if (this.tag) {
|
|
100
|
-
return onSome(this.value);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
return onNone();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Determine if this `Optional` object contains a value.
|
|
108
|
-
*/
|
|
109
|
-
isSome() {
|
|
110
|
-
return this.tag;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Determine if this `Optional` object **does not** contain a value.
|
|
114
|
-
*/
|
|
115
|
-
isNone() {
|
|
116
|
-
return !this.tag;
|
|
117
|
-
}
|
|
118
|
-
// --- Functor (name stolen from Haskell / maths) ---
|
|
119
|
-
/**
|
|
120
|
-
* Perform a transform on an `Optional` object, **if** there is a value. If
|
|
121
|
-
* you provide a function to turn a T into a U, this is the function you use
|
|
122
|
-
* to turn an `Optional<T>` into an `Optional<U>`. If this **does** contain
|
|
123
|
-
* a value then the output will also contain a value (that value being the
|
|
124
|
-
* output of `mapper(this.value)`), and if this **does not** contain a value
|
|
125
|
-
* then neither will the output.
|
|
126
|
-
*/
|
|
127
|
-
map(mapper) {
|
|
128
|
-
if (this.tag) {
|
|
129
|
-
return Optional.some(mapper(this.value));
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
return Optional.none();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// --- Monad (name stolen from Haskell / maths) ---
|
|
136
|
-
/**
|
|
137
|
-
* Perform a transform on an `Optional` object, **if** there is a value.
|
|
138
|
-
* Unlike `map`, here the transform itself also returns an `Optional`.
|
|
139
|
-
*/
|
|
140
|
-
bind(binder) {
|
|
141
|
-
if (this.tag) {
|
|
142
|
-
return binder(this.value);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return Optional.none();
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// --- Traversable (name stolen from Haskell / maths) ---
|
|
149
|
-
/**
|
|
150
|
-
* For a given predicate, this function finds out if there **exists** a value
|
|
151
|
-
* inside this `Optional` object that meets the predicate. In practice, this
|
|
152
|
-
* means that for `Optional`s that do not contain a value it returns false (as
|
|
153
|
-
* no predicate-meeting value exists).
|
|
154
|
-
*/
|
|
155
|
-
exists(predicate) {
|
|
156
|
-
return this.tag && predicate(this.value);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* For a given predicate, this function finds out if **all** the values inside
|
|
160
|
-
* this `Optional` object meet the predicate. In practice, this means that
|
|
161
|
-
* for `Optional`s that do not contain a value it returns true (as all 0
|
|
162
|
-
* objects do meet the predicate).
|
|
163
|
-
*/
|
|
164
|
-
forall(predicate) {
|
|
165
|
-
return !this.tag || predicate(this.value);
|
|
166
|
-
}
|
|
167
|
-
filter(predicate) {
|
|
168
|
-
if (!this.tag || predicate(this.value)) {
|
|
169
|
-
return this;
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
return Optional.none();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
// --- Getters ---
|
|
176
|
-
/**
|
|
177
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
178
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
179
|
-
* value.
|
|
180
|
-
*/
|
|
181
|
-
getOr(replacement) {
|
|
182
|
-
return this.tag ? this.value : replacement;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
186
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
187
|
-
* value. Unlike `getOr`, in this method the `replacement` object is also
|
|
188
|
-
* `Optional` - meaning that this method will always return an `Optional`.
|
|
189
|
-
*/
|
|
190
|
-
or(replacement) {
|
|
191
|
-
return this.tag ? this : replacement;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
195
|
-
* `replacement` value if the provided `Optional` object does not contain a
|
|
196
|
-
* value. Unlike `getOr`, in this method the `replacement` value is
|
|
197
|
-
* "thunked" - that is to say that you don't pass a value to `getOrThunk`, you
|
|
198
|
-
* pass a function which (if called) will **return** the `value` you want to
|
|
199
|
-
* use.
|
|
200
|
-
*/
|
|
201
|
-
getOrThunk(thunk) {
|
|
202
|
-
return this.tag ? this.value : thunk();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Get the value out of the inside of the `Optional` object, using a default
|
|
206
|
-
* `replacement` value if the provided Optional object does not contain a
|
|
207
|
-
* value.
|
|
208
|
-
*
|
|
209
|
-
* Unlike `or`, in this method the `replacement` value is "thunked" - that is
|
|
210
|
-
* to say that you don't pass a value to `orThunk`, you pass a function which
|
|
211
|
-
* (if called) will **return** the `value` you want to use.
|
|
212
|
-
*
|
|
213
|
-
* Unlike `getOrThunk`, in this method the `replacement` value is also
|
|
214
|
-
* `Optional`, meaning that this method will always return an `Optional`.
|
|
215
|
-
*/
|
|
216
|
-
orThunk(thunk) {
|
|
217
|
-
return this.tag ? this : thunk();
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Get the value out of the inside of the `Optional` object, throwing an
|
|
221
|
-
* exception if the provided `Optional` object does not contain a value.
|
|
222
|
-
*
|
|
223
|
-
* WARNING:
|
|
224
|
-
* You should only be using this function if you know that the `Optional`
|
|
225
|
-
* object **is not** empty (otherwise you're throwing exceptions in production
|
|
226
|
-
* code, which is bad).
|
|
227
|
-
*
|
|
228
|
-
* In tests this is more acceptable.
|
|
229
|
-
*
|
|
230
|
-
* Prefer other methods to this, such as `.each`.
|
|
231
|
-
*/
|
|
232
|
-
getOrDie(message) {
|
|
233
|
-
if (!this.tag) {
|
|
234
|
-
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
return this.value;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// --- Interop with null and undefined ---
|
|
241
|
-
/**
|
|
242
|
-
* Creates an `Optional` value from a nullable (or undefined-able) input.
|
|
243
|
-
* Null, or undefined, is converted to `None`, and anything else is converted
|
|
244
|
-
* to `Some`.
|
|
245
|
-
*/
|
|
246
|
-
static from(value) {
|
|
247
|
-
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Converts an `Optional` to a nullable type, by getting the value if it
|
|
251
|
-
* exists, or returning `null` if it does not.
|
|
252
|
-
*/
|
|
253
|
-
getOrNull() {
|
|
254
|
-
return this.tag ? this.value : null;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Converts an `Optional` to an undefined-able type, by getting the value if
|
|
258
|
-
* it exists, or returning `undefined` if it does not.
|
|
259
|
-
*/
|
|
260
|
-
getOrUndefined() {
|
|
261
|
-
return this.value;
|
|
262
|
-
}
|
|
263
|
-
// --- Utilities ---
|
|
264
|
-
/**
|
|
265
|
-
* If the `Optional` contains a value, perform an action on that value.
|
|
266
|
-
* Unlike the rest of the methods on this type, `.each` has side-effects. If
|
|
267
|
-
* you want to transform an `Optional<T>` **into** something, then this is not
|
|
268
|
-
* the method for you. If you want to use an `Optional<T>` to **do**
|
|
269
|
-
* something, then this is the method for you - provided you're okay with not
|
|
270
|
-
* doing anything in the case where the `Optional` doesn't have a value inside
|
|
271
|
-
* it. If you're not sure whether your use-case fits into transforming
|
|
272
|
-
* **into** something or **doing** something, check whether it has a return
|
|
273
|
-
* value. If it does, you should be performing a transform.
|
|
274
|
-
*/
|
|
275
|
-
each(worker) {
|
|
276
|
-
if (this.tag) {
|
|
277
|
-
worker(this.value);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Turn the `Optional` object into an array that contains all of the values
|
|
282
|
-
* stored inside the `Optional`. In practice, this means the output will have
|
|
283
|
-
* either 0 or 1 elements.
|
|
284
|
-
*/
|
|
285
|
-
toArray() {
|
|
286
|
-
return this.tag ? [this.value] : [];
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Turn the `Optional` object into a string for debugging or printing. Not
|
|
290
|
-
* recommended for production code, but good for debugging. Also note that
|
|
291
|
-
* these days an `Optional` object can be logged to the console directly, and
|
|
292
|
-
* its inner value (if it exists) will be visible.
|
|
293
|
-
*/
|
|
294
|
-
toString() {
|
|
295
|
-
return this.tag ? `some(${this.value})` : 'none()';
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
// Sneaky optimisation: every instance of Optional.none is identical, so just
|
|
299
|
-
// reuse the same object
|
|
300
|
-
Optional.singletonNone = new Optional(false);
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Adds two numbers, and wrap to a range.
|
|
304
|
-
* If the result overflows to the right, snap to the left.
|
|
305
|
-
* If the result overflows to the left, snap to the right.
|
|
306
|
-
*/
|
|
307
|
-
// the division is meant to get a number between 0 and 1 for more information check this discussion: https://stackoverflow.com/questions/58285941/how-to-replace-math-random-with-crypto-getrandomvalues-and-keep-same-result
|
|
308
|
-
const random = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295;
|
|
78
|
+
const getTextSelectionToolbarItems = option('quickbars_selection_toolbar');
|
|
79
|
+
const getInsertToolbarItems = option('quickbars_insert_toolbar');
|
|
80
|
+
const getImageToolbarItems = option('quickbars_image_toolbar');
|
|
309
81
|
|
|
310
|
-
/**
|
|
311
|
-
* Generate a unique identifier.
|
|
312
|
-
*
|
|
313
|
-
* The unique portion of the identifier only contains an underscore
|
|
314
|
-
* and digits, so that it may safely be used within HTML attributes.
|
|
315
|
-
*
|
|
316
|
-
* The chance of generating a non-unique identifier has been minimized
|
|
317
|
-
* by combining the current time, a random number and a one-up counter.
|
|
318
|
-
*
|
|
319
|
-
* generate :: String -> String
|
|
320
|
-
*/
|
|
321
82
|
let unique = 0;
|
|
322
|
-
const generate =
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
83
|
+
const generate = prefix => {
|
|
84
|
+
const date = new Date();
|
|
85
|
+
const time = date.getTime();
|
|
86
|
+
const random = Math.floor(Math.random() * 1000000000);
|
|
87
|
+
unique++;
|
|
88
|
+
return prefix + '_' + random + unique + String(time);
|
|
328
89
|
};
|
|
329
90
|
|
|
330
91
|
const insertTable = (editor, columns, rows) => {
|
|
331
|
-
|
|
92
|
+
editor.execCommand('mceInsertTable', false, {
|
|
93
|
+
rows,
|
|
94
|
+
columns
|
|
95
|
+
});
|
|
332
96
|
};
|
|
333
97
|
const insertBlob = (editor, base64, blob) => {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
98
|
+
const blobCache = editor.editorUpload.blobCache;
|
|
99
|
+
const blobInfo = blobCache.create(generate('mceu'), blob, base64);
|
|
100
|
+
blobCache.add(blobInfo);
|
|
101
|
+
editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() }));
|
|
338
102
|
};
|
|
339
103
|
|
|
340
|
-
const blobToBase64 =
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
104
|
+
const blobToBase64 = blob => {
|
|
105
|
+
return new Promise(resolve => {
|
|
106
|
+
const reader = new FileReader();
|
|
107
|
+
reader.onloadend = () => {
|
|
108
|
+
resolve(reader.result.split(',')[1]);
|
|
109
|
+
};
|
|
110
|
+
reader.readAsDataURL(blob);
|
|
111
|
+
});
|
|
348
112
|
};
|
|
349
113
|
|
|
350
114
|
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
351
115
|
|
|
352
|
-
const pickFile =
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
};
|
|
379
|
-
if (!resolved) {
|
|
380
|
-
if (e.type === 'focusin') {
|
|
381
|
-
// Chrome will fire `focusin` before the input `change` event
|
|
382
|
-
global.setEditorTimeout(editor, cleanup, 1000);
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
cleanup();
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
editor.off('focusin remove', cancelHandler);
|
|
116
|
+
const pickFile = editor => new Promise(resolve => {
|
|
117
|
+
let resolved = false;
|
|
118
|
+
const fileInput = document.createElement('input');
|
|
119
|
+
fileInput.type = 'file';
|
|
120
|
+
fileInput.accept = 'image/*';
|
|
121
|
+
fileInput.style.position = 'fixed';
|
|
122
|
+
fileInput.style.left = '0';
|
|
123
|
+
fileInput.style.top = '0';
|
|
124
|
+
fileInput.style.opacity = '0.001';
|
|
125
|
+
document.body.appendChild(fileInput);
|
|
126
|
+
const resolveFileInput = value => {
|
|
127
|
+
var _a;
|
|
128
|
+
if (!resolved) {
|
|
129
|
+
(_a = fileInput.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(fileInput);
|
|
130
|
+
resolved = true;
|
|
131
|
+
resolve(value);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const changeHandler = e => {
|
|
135
|
+
resolveFileInput(Array.prototype.slice.call(e.target.files));
|
|
136
|
+
};
|
|
137
|
+
fileInput.addEventListener('input', changeHandler);
|
|
138
|
+
fileInput.addEventListener('change', changeHandler);
|
|
139
|
+
const cancelHandler = e => {
|
|
140
|
+
const cleanup = () => {
|
|
141
|
+
resolveFileInput([]);
|
|
389
142
|
};
|
|
390
|
-
|
|
391
|
-
|
|
143
|
+
if (!resolved) {
|
|
144
|
+
if (e.type === 'focusin') {
|
|
145
|
+
global.setEditorTimeout(editor, cleanup, 1000);
|
|
146
|
+
} else {
|
|
147
|
+
cleanup();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
editor.off('focusin remove', cancelHandler);
|
|
151
|
+
};
|
|
152
|
+
editor.on('focusin remove', cancelHandler);
|
|
153
|
+
fileInput.click();
|
|
392
154
|
});
|
|
393
155
|
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
});
|
|
156
|
+
const setupButtons = editor => {
|
|
157
|
+
editor.ui.registry.addButton('quickimage', {
|
|
158
|
+
icon: 'image',
|
|
159
|
+
tooltip: 'Insert image',
|
|
160
|
+
onAction: () => {
|
|
161
|
+
pickFile(editor).then(files => {
|
|
162
|
+
if (files.length > 0) {
|
|
163
|
+
const blob = files[0];
|
|
164
|
+
blobToBase64(blob).then(base64 => {
|
|
165
|
+
insertBlob(editor, base64, blob);
|
|
166
|
+
});
|
|
409
167
|
}
|
|
410
|
-
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
editor.ui.registry.addButton('quicktable', {
|
|
172
|
+
icon: 'table',
|
|
173
|
+
tooltip: 'Insert table',
|
|
174
|
+
onAction: () => {
|
|
175
|
+
insertTable(editor, 2, 2);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
411
178
|
};
|
|
412
179
|
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const valid = isBoolean(value) || isString(value);
|
|
418
|
-
if (valid) {
|
|
419
|
-
if (isBoolean(value)) {
|
|
420
|
-
return { value: value ? defaultValue : '', valid };
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
return { value: value.trim(), valid };
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
return { valid: false, message: 'Must be a boolean or string.' };
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
const defaultSelectionToolbar = 'bold italic | quicklink h2 h3 blockquote';
|
|
431
|
-
registerOption('quickbars_selection_toolbar', {
|
|
432
|
-
processor: toolbarProcessor(defaultSelectionToolbar),
|
|
433
|
-
default: defaultSelectionToolbar
|
|
434
|
-
});
|
|
435
|
-
const defaultInsertToolbar = 'quickimage quicktable';
|
|
436
|
-
registerOption('quickbars_insert_toolbar', {
|
|
437
|
-
processor: toolbarProcessor(defaultInsertToolbar),
|
|
438
|
-
default: defaultInsertToolbar
|
|
439
|
-
});
|
|
440
|
-
const defaultImageToolbar = 'alignleft aligncenter alignright';
|
|
441
|
-
registerOption('quickbars_image_toolbar', {
|
|
442
|
-
processor: toolbarProcessor(defaultImageToolbar),
|
|
443
|
-
default: defaultImageToolbar
|
|
444
|
-
});
|
|
180
|
+
const constant = value => {
|
|
181
|
+
return () => {
|
|
182
|
+
return value;
|
|
183
|
+
};
|
|
445
184
|
};
|
|
446
|
-
const
|
|
447
|
-
const getInsertToolbarItems = option('quickbars_insert_toolbar');
|
|
448
|
-
const getImageToolbarItems = option('quickbars_image_toolbar');
|
|
185
|
+
const never = constant(false);
|
|
449
186
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
187
|
+
class Optional {
|
|
188
|
+
constructor(tag, value) {
|
|
189
|
+
this.tag = tag;
|
|
190
|
+
this.value = value;
|
|
191
|
+
}
|
|
192
|
+
static some(value) {
|
|
193
|
+
return new Optional(true, value);
|
|
194
|
+
}
|
|
195
|
+
static none() {
|
|
196
|
+
return Optional.singletonNone;
|
|
197
|
+
}
|
|
198
|
+
fold(onNone, onSome) {
|
|
199
|
+
if (this.tag) {
|
|
200
|
+
return onSome(this.value);
|
|
201
|
+
} else {
|
|
202
|
+
return onNone();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
isSome() {
|
|
206
|
+
return this.tag;
|
|
207
|
+
}
|
|
208
|
+
isNone() {
|
|
209
|
+
return !this.tag;
|
|
210
|
+
}
|
|
211
|
+
map(mapper) {
|
|
212
|
+
if (this.tag) {
|
|
213
|
+
return Optional.some(mapper(this.value));
|
|
214
|
+
} else {
|
|
215
|
+
return Optional.none();
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
bind(binder) {
|
|
219
|
+
if (this.tag) {
|
|
220
|
+
return binder(this.value);
|
|
221
|
+
} else {
|
|
222
|
+
return Optional.none();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exists(predicate) {
|
|
226
|
+
return this.tag && predicate(this.value);
|
|
227
|
+
}
|
|
228
|
+
forall(predicate) {
|
|
229
|
+
return !this.tag || predicate(this.value);
|
|
230
|
+
}
|
|
231
|
+
filter(predicate) {
|
|
232
|
+
if (!this.tag || predicate(this.value)) {
|
|
233
|
+
return this;
|
|
234
|
+
} else {
|
|
235
|
+
return Optional.none();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
getOr(replacement) {
|
|
239
|
+
return this.tag ? this.value : replacement;
|
|
240
|
+
}
|
|
241
|
+
or(replacement) {
|
|
242
|
+
return this.tag ? this : replacement;
|
|
243
|
+
}
|
|
244
|
+
getOrThunk(thunk) {
|
|
245
|
+
return this.tag ? this.value : thunk();
|
|
246
|
+
}
|
|
247
|
+
orThunk(thunk) {
|
|
248
|
+
return this.tag ? this : thunk();
|
|
249
|
+
}
|
|
250
|
+
getOrDie(message) {
|
|
251
|
+
if (!this.tag) {
|
|
252
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
253
|
+
} else {
|
|
254
|
+
return this.value;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
static from(value) {
|
|
258
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
259
|
+
}
|
|
260
|
+
getOrNull() {
|
|
261
|
+
return this.tag ? this.value : null;
|
|
262
|
+
}
|
|
263
|
+
getOrUndefined() {
|
|
264
|
+
return this.value;
|
|
265
|
+
}
|
|
266
|
+
each(worker) {
|
|
267
|
+
if (this.tag) {
|
|
268
|
+
worker(this.value);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
toArray() {
|
|
272
|
+
return this.tag ? [this.value] : [];
|
|
273
|
+
}
|
|
274
|
+
toString() {
|
|
275
|
+
return this.tag ? `some(${ this.value })` : 'none()';
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
Optional.singletonNone = new Optional(false);
|
|
279
|
+
|
|
280
|
+
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
281
|
+
|
|
282
|
+
const ELEMENT = 1;
|
|
283
|
+
|
|
284
|
+
const name = element => {
|
|
285
|
+
const r = element.dom.nodeName;
|
|
286
|
+
return r.toLowerCase();
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const has$1 = (element, key) => {
|
|
290
|
+
const dom = element.dom;
|
|
291
|
+
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
var ClosestOrAncestor = (is, ancestor, scope, a, isRoot) => {
|
|
295
|
+
if (is(scope, a)) {
|
|
296
|
+
return Optional.some(scope);
|
|
297
|
+
} else if (isFunction(isRoot) && isRoot(scope)) {
|
|
298
|
+
return Optional.none();
|
|
299
|
+
} else {
|
|
300
|
+
return ancestor(scope, a, isRoot);
|
|
301
|
+
}
|
|
463
302
|
};
|
|
464
303
|
|
|
465
304
|
const fromHtml = (html, scope) => {
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
return fromDom(div.childNodes[0]);
|
|
305
|
+
const doc = scope || document;
|
|
306
|
+
const div = doc.createElement('div');
|
|
307
|
+
div.innerHTML = html;
|
|
308
|
+
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
309
|
+
const message = 'HTML does not have a single root node';
|
|
310
|
+
console.error(message, html);
|
|
311
|
+
throw new Error(message);
|
|
312
|
+
}
|
|
313
|
+
return fromDom(div.childNodes[0]);
|
|
476
314
|
};
|
|
477
315
|
const fromTag = (tag, scope) => {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
316
|
+
const doc = scope || document;
|
|
317
|
+
const node = doc.createElement(tag);
|
|
318
|
+
return fromDom(node);
|
|
481
319
|
};
|
|
482
320
|
const fromText = (text, scope) => {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
321
|
+
const doc = scope || document;
|
|
322
|
+
const node = doc.createTextNode(text);
|
|
323
|
+
return fromDom(node);
|
|
486
324
|
};
|
|
487
|
-
const fromDom =
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
return {
|
|
493
|
-
dom: node
|
|
494
|
-
};
|
|
325
|
+
const fromDom = node => {
|
|
326
|
+
if (node === null || node === undefined) {
|
|
327
|
+
throw new Error('Node cannot be null or undefined');
|
|
328
|
+
}
|
|
329
|
+
return { dom: node };
|
|
495
330
|
};
|
|
496
331
|
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
497
|
-
// tslint:disable-next-line:variable-name
|
|
498
332
|
const SugarElement = {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
333
|
+
fromHtml,
|
|
334
|
+
fromTag,
|
|
335
|
+
fromText,
|
|
336
|
+
fromDom,
|
|
337
|
+
fromPoint
|
|
504
338
|
};
|
|
505
339
|
|
|
506
|
-
const ELEMENT = 1;
|
|
507
|
-
|
|
508
340
|
const is = (element, selector) => {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
return elem.mozMatchesSelector(selector);
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
throw new Error('Browser lacks native selectors');
|
|
530
|
-
} // unfortunately we can't throw this on startup :(
|
|
531
|
-
}
|
|
341
|
+
const dom = element.dom;
|
|
342
|
+
if (dom.nodeType !== ELEMENT) {
|
|
343
|
+
return false;
|
|
344
|
+
} else {
|
|
345
|
+
const elem = dom;
|
|
346
|
+
if (elem.matches !== undefined) {
|
|
347
|
+
return elem.matches(selector);
|
|
348
|
+
} else if (elem.msMatchesSelector !== undefined) {
|
|
349
|
+
return elem.msMatchesSelector(selector);
|
|
350
|
+
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
351
|
+
return elem.webkitMatchesSelector(selector);
|
|
352
|
+
} else if (elem.mozMatchesSelector !== undefined) {
|
|
353
|
+
return elem.mozMatchesSelector(selector);
|
|
354
|
+
} else {
|
|
355
|
+
throw new Error('Browser lacks native selectors');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
532
358
|
};
|
|
533
359
|
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
360
|
+
const ancestor$1 = (scope, predicate, isRoot) => {
|
|
361
|
+
let element = scope.dom;
|
|
362
|
+
const stop = isFunction(isRoot) ? isRoot : never;
|
|
363
|
+
while (element.parentNode) {
|
|
364
|
+
element = element.parentNode;
|
|
365
|
+
const el = SugarElement.fromDom(element);
|
|
366
|
+
if (predicate(el)) {
|
|
367
|
+
return Optional.some(el);
|
|
368
|
+
} else if (stop(el)) {
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return Optional.none();
|
|
537
373
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
// return false for non-element nodes, no point in throwing an error
|
|
542
|
-
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
|
|
374
|
+
const closest$2 = (scope, predicate, isRoot) => {
|
|
375
|
+
const is = (s, test) => test(s);
|
|
376
|
+
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
|
|
543
377
|
};
|
|
544
378
|
|
|
545
|
-
|
|
546
|
-
if (is(scope, a)) {
|
|
547
|
-
return Optional.some(scope);
|
|
548
|
-
}
|
|
549
|
-
else if (isFunction(isRoot) && isRoot(scope)) {
|
|
550
|
-
return Optional.none();
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
return ancestor(scope, a, isRoot);
|
|
554
|
-
}
|
|
555
|
-
};
|
|
379
|
+
const closest$1 = (scope, predicate, isRoot) => closest$2(scope, predicate, isRoot).isSome();
|
|
556
380
|
|
|
557
|
-
const ancestor
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
element = element.parentNode;
|
|
562
|
-
const el = SugarElement.fromDom(element);
|
|
563
|
-
if (predicate(el)) {
|
|
564
|
-
return Optional.some(el);
|
|
565
|
-
}
|
|
566
|
-
else if (stop(el)) {
|
|
567
|
-
break;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
return Optional.none();
|
|
571
|
-
};
|
|
572
|
-
const closest$2 = (scope, predicate, isRoot) => {
|
|
573
|
-
// This is required to avoid ClosestOrAncestor passing the predicate to itself
|
|
574
|
-
const is = (s, test) => test(s);
|
|
575
|
-
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
|
|
381
|
+
const ancestor = (scope, selector, isRoot) => ancestor$1(scope, e => is(e, selector), isRoot);
|
|
382
|
+
const closest = (scope, selector, isRoot) => {
|
|
383
|
+
const is$1 = (element, selector) => is(element, selector);
|
|
384
|
+
return ClosestOrAncestor(is$1, ancestor, scope, selector, isRoot);
|
|
576
385
|
};
|
|
577
386
|
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
387
|
+
const addToEditor$1 = editor => {
|
|
388
|
+
const insertToolbarItems = getInsertToolbarItems(editor);
|
|
389
|
+
if (insertToolbarItems.length > 0) {
|
|
390
|
+
editor.ui.registry.addContextToolbar('quickblock', {
|
|
391
|
+
predicate: node => {
|
|
392
|
+
const sugarNode = SugarElement.fromDom(node);
|
|
393
|
+
const textBlockElementsMap = editor.schema.getTextBlockElements();
|
|
394
|
+
const isRoot = elem => elem.dom === editor.getBody();
|
|
395
|
+
return !has$1(sugarNode, 'data-mce-bogus') && closest(sugarNode, 'table,[data-mce-bogus="all"]', isRoot).fold(() => closest$1(sugarNode, elem => name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom), isRoot), never);
|
|
396
|
+
},
|
|
397
|
+
items: insertToolbarItems,
|
|
398
|
+
position: 'line',
|
|
399
|
+
scope: 'editor'
|
|
400
|
+
});
|
|
401
|
+
}
|
|
583
402
|
};
|
|
584
403
|
|
|
585
|
-
|
|
586
|
-
const supports = (element) => element.dom.classList !== undefined;
|
|
404
|
+
const supports = element => element.dom.classList !== undefined;
|
|
587
405
|
|
|
588
406
|
const has = (element, clazz) => supports(element) && element.dom.classList.contains(clazz);
|
|
589
407
|
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
return isImage && isInEditableContext(node) && !isPagebreak;
|
|
617
|
-
};
|
|
618
|
-
const imageToolbarItems = getImageToolbarItems(editor);
|
|
619
|
-
if (imageToolbarItems.length > 0) {
|
|
620
|
-
editor.ui.registry.addContextToolbar('imageselection', {
|
|
621
|
-
predicate: isImage,
|
|
622
|
-
items: imageToolbarItems,
|
|
623
|
-
position: 'node'
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
const textToolbarItems = getTextSelectionToolbarItems(editor);
|
|
627
|
-
if (textToolbarItems.length > 0) {
|
|
628
|
-
editor.ui.registry.addContextToolbar('textselection', {
|
|
629
|
-
predicate: (node) => !isImage(node) && !editor.selection.isCollapsed() && isEditable(node),
|
|
630
|
-
items: textToolbarItems,
|
|
631
|
-
position: 'selection',
|
|
632
|
-
scope: 'editor'
|
|
633
|
-
});
|
|
634
|
-
}
|
|
408
|
+
const addToEditor = editor => {
|
|
409
|
+
const isEditable = node => editor.dom.isEditable(node);
|
|
410
|
+
const isInEditableContext = el => isEditable(el.parentElement);
|
|
411
|
+
const isImage = node => {
|
|
412
|
+
const isImageFigure = node.nodeName === 'FIGURE' && /image/i.test(node.className);
|
|
413
|
+
const isImage = node.nodeName === 'IMG' || isImageFigure;
|
|
414
|
+
const isPagebreak = has(SugarElement.fromDom(node), 'mce-pagebreak');
|
|
415
|
+
return isImage && isInEditableContext(node) && !isPagebreak;
|
|
416
|
+
};
|
|
417
|
+
const imageToolbarItems = getImageToolbarItems(editor);
|
|
418
|
+
if (imageToolbarItems.length > 0) {
|
|
419
|
+
editor.ui.registry.addContextToolbar('imageselection', {
|
|
420
|
+
predicate: isImage,
|
|
421
|
+
items: imageToolbarItems,
|
|
422
|
+
position: 'node'
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
const textToolbarItems = getTextSelectionToolbarItems(editor);
|
|
426
|
+
if (textToolbarItems.length > 0) {
|
|
427
|
+
editor.ui.registry.addContextToolbar('textselection', {
|
|
428
|
+
predicate: node => !isImage(node) && !editor.selection.isCollapsed() && isEditable(node),
|
|
429
|
+
items: textToolbarItems,
|
|
430
|
+
position: 'selection',
|
|
431
|
+
scope: 'editor'
|
|
432
|
+
});
|
|
433
|
+
}
|
|
635
434
|
};
|
|
636
435
|
|
|
637
436
|
var Plugin = () => {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
});
|
|
437
|
+
global$1.add('quickbars', editor => {
|
|
438
|
+
register(editor);
|
|
439
|
+
setupButtons(editor);
|
|
440
|
+
addToEditor$1(editor);
|
|
441
|
+
addToEditor(editor);
|
|
442
|
+
});
|
|
645
443
|
};
|
|
646
444
|
|
|
647
445
|
Plugin();
|
|
648
|
-
/** *****
|
|
649
|
-
* DO NOT EXPORT ANYTHING
|
|
650
|
-
*
|
|
651
|
-
* IF YOU DO ROLLUP WILL LEAVE A GLOBAL ON THE PAGE
|
|
652
|
-
*******/
|
|
653
446
|
|
|
654
447
|
})();
|