@dangl/angular-material-shared 2.5.1-beta0012 → 2.6.0-beta0019
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/README.md +1 -7
- package/esm2022/lib/angular-material-shared.module.mjs +2 -2
- package/esm2022/lib/components/tiny-mce/tiny-mce.component.mjs +16 -19
- package/fesm2022/dangl-angular-material-shared.mjs +16 -19
- package/fesm2022/dangl-angular-material-shared.mjs.map +1 -1
- package/lib/components/tiny-mce/tiny-mce.component.d.ts +7 -8
- package/package.json +1 -1
- package/tinymce-assets/icons/default/icons.js +187 -171
- package/tinymce-assets/icons/default/icons.min.js +1 -1
- package/tinymce-assets/langs/it.js +1 -1
- package/tinymce-assets/plugins/accordion/index.js +7 -0
- package/tinymce-assets/plugins/accordion/plugin.js +1054 -0
- package/tinymce-assets/plugins/accordion/plugin.min.js +4 -0
- package/tinymce-assets/plugins/advlist/plugin.js +185 -187
- package/tinymce-assets/plugins/advlist/plugin.min.js +2 -7
- package/tinymce-assets/plugins/anchor/plugin.js +79 -81
- package/tinymce-assets/plugins/anchor/plugin.min.js +2 -7
- package/tinymce-assets/plugins/autolink/plugin.js +209 -194
- package/tinymce-assets/plugins/autolink/plugin.min.js +2 -7
- package/tinymce-assets/plugins/autoresize/plugin.js +110 -102
- package/tinymce-assets/plugins/autoresize/plugin.min.js +2 -7
- package/tinymce-assets/plugins/autosave/plugin.js +125 -104
- package/tinymce-assets/plugins/autosave/plugin.min.js +2 -7
- package/tinymce-assets/plugins/charmap/plugin.js +275 -313
- package/tinymce-assets/plugins/charmap/plugin.min.js +2 -7
- package/tinymce-assets/plugins/code/plugin.js +18 -24
- package/tinymce-assets/plugins/code/plugin.min.js +2 -7
- package/tinymce-assets/plugins/codesample/plugin.js +2075 -2074
- package/tinymce-assets/plugins/codesample/plugin.min.js +2 -7
- package/tinymce-assets/plugins/directionality/plugin.js +247 -305
- package/tinymce-assets/plugins/directionality/plugin.min.js +2 -7
- package/tinymce-assets/plugins/emoticons/js/emojiimages.js +1 -9424
- package/tinymce-assets/plugins/emoticons/js/emojiimages.min.js +1 -1
- package/tinymce-assets/plugins/emoticons/js/emojis.js +1 -9423
- package/tinymce-assets/plugins/emoticons/js/emojis.min.js +1 -1
- package/tinymce-assets/plugins/emoticons/plugin.js +334 -374
- package/tinymce-assets/plugins/emoticons/plugin.min.js +2 -7
- package/tinymce-assets/plugins/fullscreen/plugin.js +740 -837
- package/tinymce-assets/plugins/fullscreen/plugin.min.js +2 -7
- package/tinymce-assets/plugins/help/js/i18n/keynav/ar.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/bg_BG.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ca.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/cs.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/da.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/de.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/el.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/en.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/es.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/eu.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/fa.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/fi.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/fr_FR.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/he_IL.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/hi.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/hr.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/hu_HU.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/id.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/it.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ja.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/kk.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ko_KR.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ms.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/nb_NO.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/nl.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/pl.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_BR.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/pt_PT.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ro.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/ru.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/sk.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/sl_SI.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/sv_SE.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/th_TH.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/tr.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/uk.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/vi.js +90 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_CN.js +84 -0
- package/tinymce-assets/plugins/help/js/i18n/keynav/zh_TW.js +90 -0
- package/tinymce-assets/plugins/help/plugin.js +411 -355
- package/tinymce-assets/plugins/help/plugin.min.js +2 -7
- package/tinymce-assets/plugins/image/plugin.js +876 -1037
- package/tinymce-assets/plugins/image/plugin.min.js +2 -7
- package/tinymce-assets/plugins/importcss/plugin.js +146 -144
- package/tinymce-assets/plugins/importcss/plugin.min.js +2 -7
- package/tinymce-assets/plugins/insertdatetime/plugin.js +93 -88
- package/tinymce-assets/plugins/insertdatetime/plugin.min.js +2 -7
- package/tinymce-assets/plugins/link/plugin.js +718 -768
- package/tinymce-assets/plugins/link/plugin.min.js +2 -7
- package/tinymce-assets/plugins/lists/plugin.js +1235 -1375
- package/tinymce-assets/plugins/lists/plugin.min.js +2 -7
- package/tinymce-assets/plugins/media/plugin.js +614 -756
- package/tinymce-assets/plugins/media/plugin.min.js +2 -7
- package/tinymce-assets/plugins/nonbreaking/plugin.js +71 -48
- package/tinymce-assets/plugins/nonbreaking/plugin.min.js +2 -7
- package/tinymce-assets/plugins/pagebreak/plugin.js +53 -40
- package/tinymce-assets/plugins/pagebreak/plugin.min.js +2 -7
- package/tinymce-assets/plugins/preview/plugin.js +36 -65
- package/tinymce-assets/plugins/preview/plugin.min.js +2 -7
- package/tinymce-assets/plugins/quickbars/plugin.js +304 -331
- package/tinymce-assets/plugins/quickbars/plugin.min.js +2 -7
- package/tinymce-assets/plugins/save/plugin.js +49 -50
- package/tinymce-assets/plugins/save/plugin.min.js +2 -7
- package/tinymce-assets/plugins/searchreplace/plugin.js +499 -571
- package/tinymce-assets/plugins/searchreplace/plugin.min.js +2 -7
- package/tinymce-assets/plugins/table/plugin.js +2572 -10617
- package/tinymce-assets/plugins/table/plugin.min.js +2 -7
- package/tinymce-assets/plugins/visualblocks/plugin.js +41 -46
- package/tinymce-assets/plugins/visualblocks/plugin.min.js +2 -7
- package/tinymce-assets/plugins/visualchars/plugin.js +346 -312
- package/tinymce-assets/plugins/visualchars/plugin.min.js +2 -7
- package/tinymce-assets/plugins/wordcount/plugin.js +159 -179
- package/tinymce-assets/plugins/wordcount/plugin.min.js +2 -7
- package/tinymce-assets/skins/content/dark/content.css +2 -8
- package/tinymce-assets/skins/content/dark/content.js +2 -0
- package/tinymce-assets/skins/content/dark/content.min.css +1 -7
- package/tinymce-assets/skins/content/default/content.css +0 -6
- package/tinymce-assets/skins/content/default/content.js +2 -0
- package/tinymce-assets/skins/content/default/content.min.css +0 -6
- package/tinymce-assets/skins/content/document/content.css +0 -6
- package/tinymce-assets/skins/content/document/content.js +2 -0
- package/tinymce-assets/skins/content/document/content.min.css +0 -6
- package/tinymce-assets/skins/content/tinymce-5/content.css +61 -0
- package/tinymce-assets/skins/content/tinymce-5/content.js +2 -0
- package/tinymce-assets/skins/content/tinymce-5/content.min.css +1 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.css +66 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.js +2 -0
- package/tinymce-assets/skins/content/tinymce-5-dark/content.min.css +1 -0
- package/tinymce-assets/skins/content/writer/content.css +0 -6
- package/tinymce-assets/skins/content/writer/content.js +2 -0
- package/tinymce-assets/skins/content/writer/content.min.css +0 -6
- package/tinymce-assets/skins/ui/oxide/content.css +73 -20
- package/tinymce-assets/skins/ui/oxide/content.inline.css +73 -20
- package/tinymce-assets/skins/ui/oxide/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/oxide/content.inline.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide/content.js +2 -0
- package/tinymce-assets/skins/ui/oxide/content.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide/skin.css +1480 -435
- package/tinymce-assets/skins/ui/oxide/skin.js +2 -0
- package/tinymce-assets/skins/ui/oxide/skin.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.css +1 -8
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/oxide/skin.shadowdom.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/content.css +71 -19
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.css +73 -20
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/content.inline.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/content.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/content.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/skin.css +1498 -450
- package/tinymce-assets/skins/ui/oxide-dark/skin.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/skin.min.css +1 -7
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.css +1 -8
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/oxide-dark/skin.shadowdom.min.css +1 -7
- package/tinymce-assets/skins/ui/tinymce-5/content.css +785 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.css +779 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.inline.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/content.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.css +4185 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.css +30 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5/skin.shadowdom.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.css +766 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.css +779 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.inline.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/content.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.css +4185 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.min.css +1 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.css +30 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.js +2 -0
- package/tinymce-assets/skins/ui/tinymce-5-dark/skin.shadowdom.min.css +1 -0
- package/tinymce-assets/themes/silver/theme.js +25226 -28188
- package/tinymce-assets/themes/silver/theme.min.js +2 -7
- package/tinymce-assets/plugins/bbcode/index.js +0 -7
- package/tinymce-assets/plugins/bbcode/plugin.js +0 -99
- package/tinymce-assets/plugins/bbcode/plugin.min.js +0 -9
- package/tinymce-assets/plugins/colorpicker/index.js +0 -7
- package/tinymce-assets/plugins/colorpicker/plugin.js +0 -21
- package/tinymce-assets/plugins/colorpicker/plugin.min.js +0 -9
- package/tinymce-assets/plugins/contextmenu/index.js +0 -7
- package/tinymce-assets/plugins/contextmenu/plugin.js +0 -21
- package/tinymce-assets/plugins/contextmenu/plugin.min.js +0 -9
- package/tinymce-assets/plugins/fullpage/index.js +0 -7
- package/tinymce-assets/plugins/fullpage/plugin.js +0 -544
- package/tinymce-assets/plugins/fullpage/plugin.min.js +0 -9
- package/tinymce-assets/plugins/hr/index.js +0 -7
- package/tinymce-assets/plugins/hr/plugin.js +0 -45
- package/tinymce-assets/plugins/hr/plugin.min.js +0 -9
- package/tinymce-assets/plugins/imagetools/index.js +0 -7
- package/tinymce-assets/plugins/imagetools/plugin.js +0 -1531
- package/tinymce-assets/plugins/imagetools/plugin.min.js +0 -9
- package/tinymce-assets/plugins/legacyoutput/index.js +0 -7
- package/tinymce-assets/plugins/legacyoutput/plugin.js +0 -199
- package/tinymce-assets/plugins/legacyoutput/plugin.min.js +0 -9
- package/tinymce-assets/plugins/noneditable/index.js +0 -7
- package/tinymce-assets/plugins/noneditable/plugin.js +0 -117
- package/tinymce-assets/plugins/noneditable/plugin.min.js +0 -9
- package/tinymce-assets/plugins/paste/index.js +0 -7
- package/tinymce-assets/plugins/paste/plugin.js +0 -1803
- package/tinymce-assets/plugins/paste/plugin.min.js +0 -9
- package/tinymce-assets/plugins/print/index.js +0 -7
- package/tinymce-assets/plugins/print/plugin.js +0 -52
- package/tinymce-assets/plugins/print/plugin.min.js +0 -9
- package/tinymce-assets/plugins/spellchecker/index.js +0 -7
- package/tinymce-assets/plugins/spellchecker/plugin.js +0 -730
- package/tinymce-assets/plugins/spellchecker/plugin.min.js +0 -9
- package/tinymce-assets/plugins/tabfocus/index.js +0 -7
- package/tinymce-assets/plugins/tabfocus/plugin.js +0 -130
- package/tinymce-assets/plugins/tabfocus/plugin.min.js +0 -9
- package/tinymce-assets/plugins/template/index.js +0 -7
- package/tinymce-assets/plugins/template/plugin.js +0 -591
- package/tinymce-assets/plugins/template/plugin.min.js +0 -9
- package/tinymce-assets/plugins/textcolor/index.js +0 -7
- package/tinymce-assets/plugins/textcolor/plugin.js +0 -21
- package/tinymce-assets/plugins/textcolor/plugin.min.js +0 -9
- package/tinymce-assets/plugins/textpattern/index.js +0 -7
- package/tinymce-assets/plugins/textpattern/plugin.js +0 -1374
- package/tinymce-assets/plugins/textpattern/plugin.min.js +0 -9
- package/tinymce-assets/plugins/toc/index.js +0 -7
- package/tinymce-assets/plugins/toc/plugin.js +0 -238
- package/tinymce-assets/plugins/toc/plugin.min.js +0 -9
- package/tinymce-assets/skins/ui/oxide/content.mobile.css +0 -29
- package/tinymce-assets/skins/ui/oxide/content.mobile.min.css +0 -7
- package/tinymce-assets/skins/ui/oxide/fonts/tinymce-mobile.woff +0 -0
- package/tinymce-assets/skins/ui/oxide/skin.mobile.css +0 -673
- package/tinymce-assets/skins/ui/oxide/skin.mobile.min.css +0 -7
- package/tinymce-assets/skins/ui/oxide-dark/content.mobile.css +0 -29
- package/tinymce-assets/skins/ui/oxide-dark/content.mobile.min.css +0 -7
- package/tinymce-assets/skins/ui/oxide-dark/fonts/tinymce-mobile.woff +0 -0
- package/tinymce-assets/skins/ui/oxide-dark/skin.mobile.css +0 -673
- package/tinymce-assets/skins/ui/oxide-dark/skin.mobile.min.css +0 -7
- package/tinymce-assets/themes/mobile/index.js +0 -7
- package/tinymce-assets/themes/mobile/theme.js +0 -13130
- package/tinymce-assets/themes/mobile/theme.min.js +0 -9
|
@@ -1,210 +1,185 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Licensed under the LGPL or a commercial license.
|
|
4
|
-
* For LGPL see License.txt in the project root for license information.
|
|
5
|
-
* For commercial licenses see https://www.tiny.cloud/
|
|
6
|
-
*
|
|
7
|
-
* Version: 5.10.9 (2023-11-15)
|
|
2
|
+
* TinyMCE version 7.0.1 (2024-04-10)
|
|
8
3
|
*/
|
|
4
|
+
|
|
9
5
|
(function () {
|
|
10
6
|
'use strict';
|
|
11
7
|
|
|
12
|
-
var global$
|
|
8
|
+
var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
10
|
+
const getPrototypeOf = Object.getPrototypeOf;
|
|
11
|
+
const hasProto = (v, constructor, predicate) => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (predicate(v, constructor.prototype)) {
|
|
14
|
+
return true;
|
|
15
|
+
} else {
|
|
16
|
+
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
17
|
+
}
|
|
25
18
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var t = typeof x;
|
|
19
|
+
const typeOf = x => {
|
|
20
|
+
const t = typeof x;
|
|
29
21
|
if (x === null) {
|
|
30
22
|
return 'null';
|
|
31
|
-
} else if (t === 'object' &&
|
|
23
|
+
} else if (t === 'object' && Array.isArray(x)) {
|
|
32
24
|
return 'array';
|
|
33
|
-
} else if (t === 'object' && (String
|
|
25
|
+
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
34
26
|
return 'string';
|
|
35
27
|
} else {
|
|
36
28
|
return t;
|
|
37
29
|
}
|
|
38
30
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return !isNullable(a);
|
|
31
|
+
const isType = type => value => typeOf(value) === type;
|
|
32
|
+
const isSimpleType = type => value => typeof value === type;
|
|
33
|
+
const eq = t => a => t === a;
|
|
34
|
+
const is = (value, constructor) => isObject(value) && hasProto(value, constructor, (o, proto) => getPrototypeOf(o) === proto);
|
|
35
|
+
const isString = isType('string');
|
|
36
|
+
const isObject = isType('object');
|
|
37
|
+
const isPlainObject = value => is(value, Object);
|
|
38
|
+
const isArray = isType('array');
|
|
39
|
+
const isNull = eq(null);
|
|
40
|
+
const isBoolean = isSimpleType('boolean');
|
|
41
|
+
const isNullable = a => a === null || a === undefined;
|
|
42
|
+
const isNonNullable = a => !isNullable(a);
|
|
43
|
+
const isFunction = isSimpleType('function');
|
|
44
|
+
const isNumber = isSimpleType('number');
|
|
45
|
+
const isArrayOf = (value, pred) => {
|
|
46
|
+
if (isArray(value)) {
|
|
47
|
+
for (let i = 0, len = value.length; i < len; ++i) {
|
|
48
|
+
if (!pred(value[i])) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
64
55
|
};
|
|
65
|
-
var isFunction = isSimpleType('function');
|
|
66
|
-
var isNumber = isSimpleType('number');
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
var constant = function (value) {
|
|
71
|
-
return function () {
|
|
72
|
-
return value;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
var identity = function (x) {
|
|
76
|
-
return x;
|
|
57
|
+
const noop = () => {
|
|
77
58
|
};
|
|
78
|
-
var never = constant(false);
|
|
79
|
-
var always = constant(true);
|
|
80
59
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
getOrDie: function (msg) {
|
|
98
|
-
throw new Error(msg || 'error: getOrDie called on none.');
|
|
99
|
-
},
|
|
100
|
-
getOrNull: constant(null),
|
|
101
|
-
getOrUndefined: constant(undefined),
|
|
102
|
-
or: id,
|
|
103
|
-
orThunk: call,
|
|
104
|
-
map: none,
|
|
105
|
-
each: noop,
|
|
106
|
-
bind: none,
|
|
107
|
-
exists: never,
|
|
108
|
-
forall: always,
|
|
109
|
-
filter: function () {
|
|
110
|
-
return none();
|
|
111
|
-
},
|
|
112
|
-
toArray: function () {
|
|
113
|
-
return [];
|
|
114
|
-
},
|
|
115
|
-
toString: constant('none()')
|
|
116
|
-
};
|
|
117
|
-
return me;
|
|
118
|
-
}();
|
|
119
|
-
var some = function (a) {
|
|
120
|
-
var constant_a = constant(a);
|
|
121
|
-
var self = function () {
|
|
122
|
-
return me;
|
|
123
|
-
};
|
|
124
|
-
var bind = function (f) {
|
|
125
|
-
return f(a);
|
|
126
|
-
};
|
|
127
|
-
var me = {
|
|
128
|
-
fold: function (n, s) {
|
|
129
|
-
return s(a);
|
|
130
|
-
},
|
|
131
|
-
isSome: always,
|
|
132
|
-
isNone: never,
|
|
133
|
-
getOr: constant_a,
|
|
134
|
-
getOrThunk: constant_a,
|
|
135
|
-
getOrDie: constant_a,
|
|
136
|
-
getOrNull: constant_a,
|
|
137
|
-
getOrUndefined: constant_a,
|
|
138
|
-
or: self,
|
|
139
|
-
orThunk: self,
|
|
140
|
-
map: function (f) {
|
|
141
|
-
return some(f(a));
|
|
142
|
-
},
|
|
143
|
-
each: function (f) {
|
|
144
|
-
f(a);
|
|
145
|
-
},
|
|
146
|
-
bind: bind,
|
|
147
|
-
exists: bind,
|
|
148
|
-
forall: bind,
|
|
149
|
-
filter: function (f) {
|
|
150
|
-
return f(a) ? me : NONE;
|
|
151
|
-
},
|
|
152
|
-
toArray: function () {
|
|
153
|
-
return [a];
|
|
154
|
-
},
|
|
155
|
-
toString: function () {
|
|
156
|
-
return 'some(' + a + ')';
|
|
60
|
+
class Optional {
|
|
61
|
+
constructor(tag, value) {
|
|
62
|
+
this.tag = tag;
|
|
63
|
+
this.value = value;
|
|
64
|
+
}
|
|
65
|
+
static some(value) {
|
|
66
|
+
return new Optional(true, value);
|
|
67
|
+
}
|
|
68
|
+
static none() {
|
|
69
|
+
return Optional.singletonNone;
|
|
70
|
+
}
|
|
71
|
+
fold(onNone, onSome) {
|
|
72
|
+
if (this.tag) {
|
|
73
|
+
return onSome(this.value);
|
|
74
|
+
} else {
|
|
75
|
+
return onNone();
|
|
157
76
|
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
77
|
+
}
|
|
78
|
+
isSome() {
|
|
79
|
+
return this.tag;
|
|
80
|
+
}
|
|
81
|
+
isNone() {
|
|
82
|
+
return !this.tag;
|
|
83
|
+
}
|
|
84
|
+
map(mapper) {
|
|
85
|
+
if (this.tag) {
|
|
86
|
+
return Optional.some(mapper(this.value));
|
|
87
|
+
} else {
|
|
88
|
+
return Optional.none();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
bind(binder) {
|
|
92
|
+
if (this.tag) {
|
|
93
|
+
return binder(this.value);
|
|
94
|
+
} else {
|
|
95
|
+
return Optional.none();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exists(predicate) {
|
|
99
|
+
return this.tag && predicate(this.value);
|
|
100
|
+
}
|
|
101
|
+
forall(predicate) {
|
|
102
|
+
return !this.tag || predicate(this.value);
|
|
103
|
+
}
|
|
104
|
+
filter(predicate) {
|
|
105
|
+
if (!this.tag || predicate(this.value)) {
|
|
106
|
+
return this;
|
|
107
|
+
} else {
|
|
108
|
+
return Optional.none();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
getOr(replacement) {
|
|
112
|
+
return this.tag ? this.value : replacement;
|
|
113
|
+
}
|
|
114
|
+
or(replacement) {
|
|
115
|
+
return this.tag ? this : replacement;
|
|
116
|
+
}
|
|
117
|
+
getOrThunk(thunk) {
|
|
118
|
+
return this.tag ? this.value : thunk();
|
|
119
|
+
}
|
|
120
|
+
orThunk(thunk) {
|
|
121
|
+
return this.tag ? this : thunk();
|
|
122
|
+
}
|
|
123
|
+
getOrDie(message) {
|
|
124
|
+
if (!this.tag) {
|
|
125
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
126
|
+
} else {
|
|
127
|
+
return this.value;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
static from(value) {
|
|
131
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
132
|
+
}
|
|
133
|
+
getOrNull() {
|
|
134
|
+
return this.tag ? this.value : null;
|
|
135
|
+
}
|
|
136
|
+
getOrUndefined() {
|
|
137
|
+
return this.value;
|
|
138
|
+
}
|
|
139
|
+
each(worker) {
|
|
140
|
+
if (this.tag) {
|
|
141
|
+
worker(this.value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
toArray() {
|
|
145
|
+
return this.tag ? [this.value] : [];
|
|
146
|
+
}
|
|
147
|
+
toString() {
|
|
148
|
+
return this.tag ? `some(${ this.value })` : 'none()';
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
Optional.singletonNone = new Optional(false);
|
|
169
152
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
for (
|
|
175
|
-
|
|
176
|
-
|
|
153
|
+
const keys = Object.keys;
|
|
154
|
+
const hasOwnProperty = Object.hasOwnProperty;
|
|
155
|
+
const each = (obj, f) => {
|
|
156
|
+
const props = keys(obj);
|
|
157
|
+
for (let k = 0, len = props.length; k < len; k++) {
|
|
158
|
+
const i = props[k];
|
|
159
|
+
const x = obj[i];
|
|
177
160
|
f(x, i);
|
|
178
161
|
}
|
|
179
162
|
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
r[i] = x;
|
|
183
|
-
};
|
|
163
|
+
const objAcc = r => (x, i) => {
|
|
164
|
+
r[i] = x;
|
|
184
165
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
each(obj, function (x, i) {
|
|
166
|
+
const internalFilter = (obj, pred, onTrue, onFalse) => {
|
|
167
|
+
each(obj, (x, i) => {
|
|
188
168
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
189
169
|
});
|
|
190
|
-
return r;
|
|
191
170
|
};
|
|
192
|
-
|
|
193
|
-
|
|
171
|
+
const filter = (obj, pred) => {
|
|
172
|
+
const t = {};
|
|
194
173
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
195
174
|
return t;
|
|
196
175
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
};
|
|
200
|
-
var hasNonNullableKey = function (obj, key) {
|
|
201
|
-
return has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
202
|
-
};
|
|
176
|
+
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
|
177
|
+
const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
203
178
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
for (
|
|
179
|
+
const nativePush = Array.prototype.push;
|
|
180
|
+
const flatten = xs => {
|
|
181
|
+
const r = [];
|
|
182
|
+
for (let i = 0, len = xs.length; i < len; ++i) {
|
|
208
183
|
if (!isArray(xs[i])) {
|
|
209
184
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
210
185
|
}
|
|
@@ -212,15 +187,11 @@
|
|
|
212
187
|
}
|
|
213
188
|
return r;
|
|
214
189
|
};
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
};
|
|
221
|
-
var findMap = function (arr, f) {
|
|
222
|
-
for (var i = 0; i < arr.length; i++) {
|
|
223
|
-
var r = f(arr[i], i);
|
|
190
|
+
const get = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
191
|
+
const head = xs => get(xs, 0);
|
|
192
|
+
const findMap = (arr, f) => {
|
|
193
|
+
for (let i = 0; i < arr.length; i++) {
|
|
194
|
+
const r = f(arr[i], i);
|
|
224
195
|
if (r.isSome()) {
|
|
225
196
|
return r;
|
|
226
197
|
}
|
|
@@ -230,7 +201,7 @@
|
|
|
230
201
|
|
|
231
202
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
232
203
|
|
|
233
|
-
|
|
204
|
+
const rawSet = (dom, key, value) => {
|
|
234
205
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
235
206
|
dom.setAttribute(key, value + '');
|
|
236
207
|
} else {
|
|
@@ -238,147 +209,160 @@
|
|
|
238
209
|
throw new Error('Attribute value was not simple');
|
|
239
210
|
}
|
|
240
211
|
};
|
|
241
|
-
|
|
212
|
+
const set = (element, key, value) => {
|
|
242
213
|
rawSet(element.dom, key, value);
|
|
243
214
|
};
|
|
244
|
-
|
|
215
|
+
const remove = (element, key) => {
|
|
245
216
|
element.dom.removeAttribute(key);
|
|
246
217
|
};
|
|
247
218
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
219
|
+
const fromHtml = (html, scope) => {
|
|
220
|
+
const doc = scope || document;
|
|
221
|
+
const div = doc.createElement('div');
|
|
251
222
|
div.innerHTML = html;
|
|
252
223
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
253
|
-
|
|
254
|
-
|
|
224
|
+
const message = 'HTML does not have a single root node';
|
|
225
|
+
console.error(message, html);
|
|
226
|
+
throw new Error(message);
|
|
255
227
|
}
|
|
256
228
|
return fromDom(div.childNodes[0]);
|
|
257
229
|
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
230
|
+
const fromTag = (tag, scope) => {
|
|
231
|
+
const doc = scope || document;
|
|
232
|
+
const node = doc.createElement(tag);
|
|
261
233
|
return fromDom(node);
|
|
262
234
|
};
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
235
|
+
const fromText = (text, scope) => {
|
|
236
|
+
const doc = scope || document;
|
|
237
|
+
const node = doc.createTextNode(text);
|
|
266
238
|
return fromDom(node);
|
|
267
239
|
};
|
|
268
|
-
|
|
240
|
+
const fromDom = node => {
|
|
269
241
|
if (node === null || node === undefined) {
|
|
270
242
|
throw new Error('Node cannot be null or undefined');
|
|
271
243
|
}
|
|
272
244
|
return { dom: node };
|
|
273
245
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
fromDom: fromDom,
|
|
282
|
-
fromPoint: fromPoint
|
|
246
|
+
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
247
|
+
const SugarElement = {
|
|
248
|
+
fromHtml,
|
|
249
|
+
fromTag,
|
|
250
|
+
fromText,
|
|
251
|
+
fromDom,
|
|
252
|
+
fromPoint
|
|
283
253
|
};
|
|
284
254
|
|
|
285
|
-
var global$
|
|
255
|
+
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
286
256
|
|
|
287
|
-
var global$
|
|
257
|
+
var global$2 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
288
258
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
var global$2 = tinymce.util.Tools.resolve('tinymce.util.XHR');
|
|
292
|
-
|
|
293
|
-
var hasDimensions = function (editor) {
|
|
294
|
-
return editor.getParam('image_dimensions', true, 'boolean');
|
|
295
|
-
};
|
|
296
|
-
var hasAdvTab = function (editor) {
|
|
297
|
-
return editor.getParam('image_advtab', false, 'boolean');
|
|
298
|
-
};
|
|
299
|
-
var hasUploadTab = function (editor) {
|
|
300
|
-
return editor.getParam('image_uploadtab', true, 'boolean');
|
|
301
|
-
};
|
|
302
|
-
var getPrependUrl = function (editor) {
|
|
303
|
-
return editor.getParam('image_prepend_url', '', 'string');
|
|
304
|
-
};
|
|
305
|
-
var getClassList = function (editor) {
|
|
306
|
-
return editor.getParam('image_class_list');
|
|
307
|
-
};
|
|
308
|
-
var hasDescription = function (editor) {
|
|
309
|
-
return editor.getParam('image_description', true, 'boolean');
|
|
310
|
-
};
|
|
311
|
-
var hasImageTitle = function (editor) {
|
|
312
|
-
return editor.getParam('image_title', false, 'boolean');
|
|
313
|
-
};
|
|
314
|
-
var hasImageCaption = function (editor) {
|
|
315
|
-
return editor.getParam('image_caption', false, 'boolean');
|
|
316
|
-
};
|
|
317
|
-
var getImageList = function (editor) {
|
|
318
|
-
return editor.getParam('image_list', false);
|
|
319
|
-
};
|
|
320
|
-
var hasUploadUrl = function (editor) {
|
|
321
|
-
return isNonNullable(editor.getParam('images_upload_url'));
|
|
322
|
-
};
|
|
323
|
-
var hasUploadHandler = function (editor) {
|
|
324
|
-
return isNonNullable(editor.getParam('images_upload_handler'));
|
|
325
|
-
};
|
|
326
|
-
var showAccessibilityOptions = function (editor) {
|
|
327
|
-
return editor.getParam('a11y_advanced_options', false, 'boolean');
|
|
328
|
-
};
|
|
329
|
-
var isAutomaticUploadsEnabled = function (editor) {
|
|
330
|
-
return editor.getParam('automatic_uploads', true, 'boolean');
|
|
331
|
-
};
|
|
259
|
+
const isNotEmpty = s => s.length > 0;
|
|
332
260
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
261
|
+
const option = name => editor => editor.options.get(name);
|
|
262
|
+
const register$2 = editor => {
|
|
263
|
+
const registerOption = editor.options.register;
|
|
264
|
+
registerOption('image_dimensions', {
|
|
265
|
+
processor: 'boolean',
|
|
266
|
+
default: true
|
|
267
|
+
});
|
|
268
|
+
registerOption('image_advtab', {
|
|
269
|
+
processor: 'boolean',
|
|
270
|
+
default: false
|
|
271
|
+
});
|
|
272
|
+
registerOption('image_uploadtab', {
|
|
273
|
+
processor: 'boolean',
|
|
274
|
+
default: true
|
|
275
|
+
});
|
|
276
|
+
registerOption('image_prepend_url', {
|
|
277
|
+
processor: 'string',
|
|
278
|
+
default: ''
|
|
279
|
+
});
|
|
280
|
+
registerOption('image_class_list', { processor: 'object[]' });
|
|
281
|
+
registerOption('image_description', {
|
|
282
|
+
processor: 'boolean',
|
|
283
|
+
default: true
|
|
284
|
+
});
|
|
285
|
+
registerOption('image_title', {
|
|
286
|
+
processor: 'boolean',
|
|
287
|
+
default: false
|
|
288
|
+
});
|
|
289
|
+
registerOption('image_caption', {
|
|
290
|
+
processor: 'boolean',
|
|
291
|
+
default: false
|
|
292
|
+
});
|
|
293
|
+
registerOption('image_list', {
|
|
294
|
+
processor: value => {
|
|
295
|
+
const valid = value === false || isString(value) || isArrayOf(value, isObject) || isFunction(value);
|
|
296
|
+
return valid ? {
|
|
297
|
+
value,
|
|
298
|
+
valid
|
|
299
|
+
} : {
|
|
300
|
+
valid: false,
|
|
301
|
+
message: 'Must be false, a string, an array or a function.'
|
|
352
302
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
img.onerror = function () {
|
|
356
|
-
done(global$4.reject('Failed to get image dimensions for: ' + url));
|
|
357
|
-
};
|
|
358
|
-
var style = img.style;
|
|
359
|
-
style.visibility = 'hidden';
|
|
360
|
-
style.position = 'fixed';
|
|
361
|
-
style.bottom = style.left = '0px';
|
|
362
|
-
style.width = style.height = 'auto';
|
|
363
|
-
document.body.appendChild(img);
|
|
364
|
-
img.src = url;
|
|
303
|
+
},
|
|
304
|
+
default: false
|
|
365
305
|
});
|
|
366
306
|
};
|
|
367
|
-
|
|
307
|
+
const hasDimensions = option('image_dimensions');
|
|
308
|
+
const hasAdvTab = option('image_advtab');
|
|
309
|
+
const hasUploadTab = option('image_uploadtab');
|
|
310
|
+
const getPrependUrl = option('image_prepend_url');
|
|
311
|
+
const getClassList = option('image_class_list');
|
|
312
|
+
const hasDescription = option('image_description');
|
|
313
|
+
const hasImageTitle = option('image_title');
|
|
314
|
+
const hasImageCaption = option('image_caption');
|
|
315
|
+
const getImageList = option('image_list');
|
|
316
|
+
const showAccessibilityOptions = option('a11y_advanced_options');
|
|
317
|
+
const isAutomaticUploadsEnabled = option('automatic_uploads');
|
|
318
|
+
const hasUploadUrl = editor => isNotEmpty(editor.options.get('images_upload_url'));
|
|
319
|
+
const hasUploadHandler = editor => isNonNullable(editor.options.get('images_upload_handler'));
|
|
320
|
+
|
|
321
|
+
const parseIntAndGetMax = (val1, val2) => Math.max(parseInt(val1, 10), parseInt(val2, 10));
|
|
322
|
+
const getImageSize = url => new Promise(callback => {
|
|
323
|
+
const img = document.createElement('img');
|
|
324
|
+
const done = dimensions => {
|
|
325
|
+
img.onload = img.onerror = null;
|
|
326
|
+
if (img.parentNode) {
|
|
327
|
+
img.parentNode.removeChild(img);
|
|
328
|
+
}
|
|
329
|
+
callback(dimensions);
|
|
330
|
+
};
|
|
331
|
+
img.onload = () => {
|
|
332
|
+
const width = parseIntAndGetMax(img.width, img.clientWidth);
|
|
333
|
+
const height = parseIntAndGetMax(img.height, img.clientHeight);
|
|
334
|
+
const dimensions = {
|
|
335
|
+
width,
|
|
336
|
+
height
|
|
337
|
+
};
|
|
338
|
+
done(Promise.resolve(dimensions));
|
|
339
|
+
};
|
|
340
|
+
img.onerror = () => {
|
|
341
|
+
done(Promise.reject(`Failed to get image dimensions for: ${ url }`));
|
|
342
|
+
};
|
|
343
|
+
const style = img.style;
|
|
344
|
+
style.visibility = 'hidden';
|
|
345
|
+
style.position = 'fixed';
|
|
346
|
+
style.bottom = style.left = '0px';
|
|
347
|
+
style.width = style.height = 'auto';
|
|
348
|
+
document.body.appendChild(img);
|
|
349
|
+
img.src = url;
|
|
350
|
+
});
|
|
351
|
+
const removePixelSuffix = value => {
|
|
368
352
|
if (value) {
|
|
369
353
|
value = value.replace(/px$/, '');
|
|
370
354
|
}
|
|
371
355
|
return value;
|
|
372
356
|
};
|
|
373
|
-
|
|
357
|
+
const addPixelSuffix = value => {
|
|
374
358
|
if (value.length > 0 && /^[0-9]+$/.test(value)) {
|
|
375
359
|
value += 'px';
|
|
376
360
|
}
|
|
377
361
|
return value;
|
|
378
362
|
};
|
|
379
|
-
|
|
363
|
+
const mergeMargins = css => {
|
|
380
364
|
if (css.margin) {
|
|
381
|
-
|
|
365
|
+
const splitMargin = String(css.margin).split(' ');
|
|
382
366
|
switch (splitMargin.length) {
|
|
383
367
|
case 1:
|
|
384
368
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
@@ -408,13 +392,12 @@
|
|
|
408
392
|
}
|
|
409
393
|
return css;
|
|
410
394
|
};
|
|
411
|
-
|
|
412
|
-
|
|
395
|
+
const createImageList = (editor, callback) => {
|
|
396
|
+
const imageList = getImageList(editor);
|
|
413
397
|
if (isString(imageList)) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
callback(JSON.parse(text));
|
|
398
|
+
fetch(imageList).then(res => {
|
|
399
|
+
if (res.ok) {
|
|
400
|
+
res.json().then(callback);
|
|
418
401
|
}
|
|
419
402
|
});
|
|
420
403
|
} else if (isFunction(imageList)) {
|
|
@@ -423,15 +406,15 @@
|
|
|
423
406
|
callback(imageList);
|
|
424
407
|
}
|
|
425
408
|
};
|
|
426
|
-
|
|
427
|
-
|
|
409
|
+
const waitLoadImage = (editor, data, imgElm) => {
|
|
410
|
+
const selectImage = () => {
|
|
428
411
|
imgElm.onload = imgElm.onerror = null;
|
|
429
412
|
if (editor.selection) {
|
|
430
413
|
editor.selection.select(imgElm);
|
|
431
414
|
editor.nodeChanged();
|
|
432
415
|
}
|
|
433
416
|
};
|
|
434
|
-
imgElm.onload =
|
|
417
|
+
imgElm.onload = () => {
|
|
435
418
|
if (!data.width && !data.height && hasDimensions(editor)) {
|
|
436
419
|
editor.dom.setAttribs(imgElm, {
|
|
437
420
|
width: String(imgElm.clientWidth),
|
|
@@ -442,89 +425,89 @@
|
|
|
442
425
|
};
|
|
443
426
|
imgElm.onerror = selectImage;
|
|
444
427
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
reader.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
428
|
+
const blobToDataUri = blob => new Promise((resolve, reject) => {
|
|
429
|
+
const reader = new FileReader();
|
|
430
|
+
reader.onload = () => {
|
|
431
|
+
resolve(reader.result);
|
|
432
|
+
};
|
|
433
|
+
reader.onerror = () => {
|
|
434
|
+
var _a;
|
|
435
|
+
reject((_a = reader.error) === null || _a === void 0 ? void 0 : _a.message);
|
|
436
|
+
};
|
|
437
|
+
reader.readAsDataURL(blob);
|
|
438
|
+
});
|
|
439
|
+
const isPlaceholderImage = imgElm => imgElm.nodeName === 'IMG' && (imgElm.hasAttribute('data-mce-object') || imgElm.hasAttribute('data-mce-placeholder'));
|
|
440
|
+
const isSafeImageUrl = (editor, src) => {
|
|
441
|
+
const getOption = editor.options.get;
|
|
442
|
+
return global$2.isDomSafe(src, 'img', {
|
|
443
|
+
allow_html_data_urls: getOption('allow_html_data_urls'),
|
|
444
|
+
allow_script_urls: getOption('allow_script_urls'),
|
|
445
|
+
allow_svg_data_urls: getOption('allow_svg_data_urls')
|
|
455
446
|
});
|
|
456
447
|
};
|
|
457
|
-
var isPlaceholderImage = function (imgElm) {
|
|
458
|
-
return imgElm.nodeName === 'IMG' && (imgElm.hasAttribute('data-mce-object') || imgElm.hasAttribute('data-mce-placeholder'));
|
|
459
|
-
};
|
|
460
|
-
var isSafeImageUrl = function (editor, src) {
|
|
461
|
-
return global$3.isDomSafe(src, 'img', editor.settings);
|
|
462
|
-
};
|
|
463
448
|
|
|
464
|
-
|
|
465
|
-
|
|
449
|
+
const DOM = global$3.DOM;
|
|
450
|
+
const getHspace = image => {
|
|
466
451
|
if (image.style.marginLeft && image.style.marginRight && image.style.marginLeft === image.style.marginRight) {
|
|
467
452
|
return removePixelSuffix(image.style.marginLeft);
|
|
468
453
|
} else {
|
|
469
454
|
return '';
|
|
470
455
|
}
|
|
471
456
|
};
|
|
472
|
-
|
|
457
|
+
const getVspace = image => {
|
|
473
458
|
if (image.style.marginTop && image.style.marginBottom && image.style.marginTop === image.style.marginBottom) {
|
|
474
459
|
return removePixelSuffix(image.style.marginTop);
|
|
475
460
|
} else {
|
|
476
461
|
return '';
|
|
477
462
|
}
|
|
478
463
|
};
|
|
479
|
-
|
|
464
|
+
const getBorder = image => {
|
|
480
465
|
if (image.style.borderWidth) {
|
|
481
466
|
return removePixelSuffix(image.style.borderWidth);
|
|
482
467
|
} else {
|
|
483
468
|
return '';
|
|
484
469
|
}
|
|
485
470
|
};
|
|
486
|
-
|
|
471
|
+
const getAttrib = (image, name) => {
|
|
472
|
+
var _a;
|
|
487
473
|
if (image.hasAttribute(name)) {
|
|
488
|
-
return image.getAttribute(name);
|
|
474
|
+
return (_a = image.getAttribute(name)) !== null && _a !== void 0 ? _a : '';
|
|
489
475
|
} else {
|
|
490
476
|
return '';
|
|
491
477
|
}
|
|
492
478
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
var hasCaption = function (image) {
|
|
497
|
-
return image.parentNode !== null && image.parentNode.nodeName === 'FIGURE';
|
|
498
|
-
};
|
|
499
|
-
var updateAttrib = function (image, name, value) {
|
|
500
|
-
if (value === '') {
|
|
479
|
+
const hasCaption = image => image.parentNode !== null && image.parentNode.nodeName === 'FIGURE';
|
|
480
|
+
const updateAttrib = (image, name, value) => {
|
|
481
|
+
if (value === '' || value === null) {
|
|
501
482
|
image.removeAttribute(name);
|
|
502
483
|
} else {
|
|
503
484
|
image.setAttribute(name, value);
|
|
504
485
|
}
|
|
505
486
|
};
|
|
506
|
-
|
|
507
|
-
|
|
487
|
+
const wrapInFigure = image => {
|
|
488
|
+
const figureElm = DOM.create('figure', { class: 'image' });
|
|
508
489
|
DOM.insertAfter(figureElm, image);
|
|
509
490
|
figureElm.appendChild(image);
|
|
510
491
|
figureElm.appendChild(DOM.create('figcaption', { contentEditable: 'true' }, 'Caption'));
|
|
511
492
|
figureElm.contentEditable = 'false';
|
|
512
493
|
};
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
494
|
+
const removeFigure = image => {
|
|
495
|
+
const figureElm = image.parentNode;
|
|
496
|
+
if (isNonNullable(figureElm)) {
|
|
497
|
+
DOM.insertAfter(image, figureElm);
|
|
498
|
+
DOM.remove(figureElm);
|
|
499
|
+
}
|
|
517
500
|
};
|
|
518
|
-
|
|
501
|
+
const toggleCaption = image => {
|
|
519
502
|
if (hasCaption(image)) {
|
|
520
503
|
removeFigure(image);
|
|
521
504
|
} else {
|
|
522
505
|
wrapInFigure(image);
|
|
523
506
|
}
|
|
524
507
|
};
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
508
|
+
const normalizeStyle = (image, normalizeCss) => {
|
|
509
|
+
const attrValue = image.getAttribute('style');
|
|
510
|
+
const value = normalizeCss(attrValue !== null ? attrValue : '');
|
|
528
511
|
if (value.length > 0) {
|
|
529
512
|
image.setAttribute('style', value);
|
|
530
513
|
image.setAttribute('data-mce-style', value);
|
|
@@ -532,78 +515,71 @@
|
|
|
532
515
|
image.removeAttribute('style');
|
|
533
516
|
}
|
|
534
517
|
};
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
};
|
|
518
|
+
const setSize = (name, normalizeCss) => (image, name, value) => {
|
|
519
|
+
const styles = image.style;
|
|
520
|
+
if (styles[name]) {
|
|
521
|
+
styles[name] = addPixelSuffix(value);
|
|
522
|
+
normalizeStyle(image, normalizeCss);
|
|
523
|
+
} else {
|
|
524
|
+
updateAttrib(image, name, value);
|
|
525
|
+
}
|
|
544
526
|
};
|
|
545
|
-
|
|
527
|
+
const getSize = (image, name) => {
|
|
546
528
|
if (image.style[name]) {
|
|
547
529
|
return removePixelSuffix(image.style[name]);
|
|
548
530
|
} else {
|
|
549
531
|
return getAttrib(image, name);
|
|
550
532
|
}
|
|
551
533
|
};
|
|
552
|
-
|
|
553
|
-
|
|
534
|
+
const setHspace = (image, value) => {
|
|
535
|
+
const pxValue = addPixelSuffix(value);
|
|
554
536
|
image.style.marginLeft = pxValue;
|
|
555
537
|
image.style.marginRight = pxValue;
|
|
556
538
|
};
|
|
557
|
-
|
|
558
|
-
|
|
539
|
+
const setVspace = (image, value) => {
|
|
540
|
+
const pxValue = addPixelSuffix(value);
|
|
559
541
|
image.style.marginTop = pxValue;
|
|
560
542
|
image.style.marginBottom = pxValue;
|
|
561
543
|
};
|
|
562
|
-
|
|
563
|
-
|
|
544
|
+
const setBorder = (image, value) => {
|
|
545
|
+
const pxValue = addPixelSuffix(value);
|
|
564
546
|
image.style.borderWidth = pxValue;
|
|
565
547
|
};
|
|
566
|
-
|
|
548
|
+
const setBorderStyle = (image, value) => {
|
|
567
549
|
image.style.borderStyle = value;
|
|
568
550
|
};
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
var isFigure = function (elm) {
|
|
573
|
-
return elm.nodeName === 'FIGURE';
|
|
574
|
-
};
|
|
575
|
-
var isImage = function (elm) {
|
|
576
|
-
return elm.nodeName === 'IMG';
|
|
551
|
+
const getBorderStyle = image => {
|
|
552
|
+
var _a;
|
|
553
|
+
return (_a = image.style.borderStyle) !== null && _a !== void 0 ? _a : '';
|
|
577
554
|
};
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
555
|
+
const isFigure = elm => isNonNullable(elm) && elm.nodeName === 'FIGURE';
|
|
556
|
+
const isImage = elm => elm.nodeName === 'IMG';
|
|
557
|
+
const getIsDecorative = image => DOM.getAttrib(image, 'alt').length === 0 && DOM.getAttrib(image, 'role') === 'presentation';
|
|
558
|
+
const getAlt = image => {
|
|
582
559
|
if (getIsDecorative(image)) {
|
|
583
560
|
return '';
|
|
584
561
|
} else {
|
|
585
562
|
return getAttrib(image, 'alt');
|
|
586
563
|
}
|
|
587
564
|
};
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
var image = document.createElement('img');
|
|
565
|
+
const defaultData = () => ({
|
|
566
|
+
src: '',
|
|
567
|
+
alt: '',
|
|
568
|
+
title: '',
|
|
569
|
+
width: '',
|
|
570
|
+
height: '',
|
|
571
|
+
class: '',
|
|
572
|
+
style: '',
|
|
573
|
+
caption: false,
|
|
574
|
+
hspace: '',
|
|
575
|
+
vspace: '',
|
|
576
|
+
border: '',
|
|
577
|
+
borderStyle: '',
|
|
578
|
+
isDecorative: false
|
|
579
|
+
});
|
|
580
|
+
const getStyleValue = (normalizeCss, data) => {
|
|
581
|
+
var _a;
|
|
582
|
+
const image = document.createElement('img');
|
|
607
583
|
updateAttrib(image, 'style', data.style);
|
|
608
584
|
if (getHspace(image) || data.hspace !== '') {
|
|
609
585
|
setHspace(image, data.hspace);
|
|
@@ -617,14 +593,17 @@
|
|
|
617
593
|
if (getBorderStyle(image) || data.borderStyle !== '') {
|
|
618
594
|
setBorderStyle(image, data.borderStyle);
|
|
619
595
|
}
|
|
620
|
-
return normalizeCss(image.getAttribute('style'));
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
write(normalizeCss,
|
|
596
|
+
return normalizeCss((_a = image.getAttribute('style')) !== null && _a !== void 0 ? _a : '');
|
|
597
|
+
};
|
|
598
|
+
const create = (normalizeCss, data) => {
|
|
599
|
+
const image = document.createElement('img');
|
|
600
|
+
write(normalizeCss, {
|
|
601
|
+
...data,
|
|
602
|
+
caption: false
|
|
603
|
+
}, image);
|
|
625
604
|
setAlt(image, data.alt, data.isDecorative);
|
|
626
605
|
if (data.caption) {
|
|
627
|
-
|
|
606
|
+
const figure = DOM.create('figure', { class: 'image' });
|
|
628
607
|
figure.appendChild(image);
|
|
629
608
|
figure.appendChild(DOM.create('figcaption', { contentEditable: 'true' }, 'Caption'));
|
|
630
609
|
figure.contentEditable = 'false';
|
|
@@ -633,39 +612,37 @@
|
|
|
633
612
|
return image;
|
|
634
613
|
}
|
|
635
614
|
};
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
};
|
|
653
|
-
var updateProp = function (image, oldData, newData, name, set) {
|
|
615
|
+
const read = (normalizeCss, image) => ({
|
|
616
|
+
src: getAttrib(image, 'src'),
|
|
617
|
+
alt: getAlt(image),
|
|
618
|
+
title: getAttrib(image, 'title'),
|
|
619
|
+
width: getSize(image, 'width'),
|
|
620
|
+
height: getSize(image, 'height'),
|
|
621
|
+
class: getAttrib(image, 'class'),
|
|
622
|
+
style: normalizeCss(getAttrib(image, 'style')),
|
|
623
|
+
caption: hasCaption(image),
|
|
624
|
+
hspace: getHspace(image),
|
|
625
|
+
vspace: getVspace(image),
|
|
626
|
+
border: getBorder(image),
|
|
627
|
+
borderStyle: getBorderStyle(image),
|
|
628
|
+
isDecorative: getIsDecorative(image)
|
|
629
|
+
});
|
|
630
|
+
const updateProp = (image, oldData, newData, name, set) => {
|
|
654
631
|
if (newData[name] !== oldData[name]) {
|
|
655
|
-
set(image, name, newData[name]);
|
|
632
|
+
set(image, name, String(newData[name]));
|
|
656
633
|
}
|
|
657
634
|
};
|
|
658
|
-
|
|
635
|
+
const setAlt = (image, alt, isDecorative) => {
|
|
659
636
|
if (isDecorative) {
|
|
660
637
|
DOM.setAttrib(image, 'role', 'presentation');
|
|
661
|
-
|
|
638
|
+
const sugarImage = SugarElement.fromDom(image);
|
|
662
639
|
set(sugarImage, 'alt', '');
|
|
663
640
|
} else {
|
|
664
641
|
if (isNull(alt)) {
|
|
665
|
-
|
|
642
|
+
const sugarImage = SugarElement.fromDom(image);
|
|
666
643
|
remove(sugarImage, 'alt');
|
|
667
644
|
} else {
|
|
668
|
-
|
|
645
|
+
const sugarImage = SugarElement.fromDom(image);
|
|
669
646
|
set(sugarImage, 'alt', alt);
|
|
670
647
|
}
|
|
671
648
|
if (DOM.getAttrib(image, 'role') === 'presentation') {
|
|
@@ -673,30 +650,24 @@
|
|
|
673
650
|
}
|
|
674
651
|
}
|
|
675
652
|
};
|
|
676
|
-
|
|
653
|
+
const updateAlt = (image, oldData, newData) => {
|
|
677
654
|
if (newData.alt !== oldData.alt || newData.isDecorative !== oldData.isDecorative) {
|
|
678
655
|
setAlt(image, newData.alt, newData.isDecorative);
|
|
679
656
|
}
|
|
680
657
|
};
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
normalizeStyle(image, normalizeCss);
|
|
685
|
-
};
|
|
658
|
+
const normalized = (set, normalizeCss) => (image, name, value) => {
|
|
659
|
+
set(image, value);
|
|
660
|
+
normalizeStyle(image, normalizeCss);
|
|
686
661
|
};
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
updateProp(image, oldData, newData, 'caption',
|
|
690
|
-
return toggleCaption(image);
|
|
691
|
-
});
|
|
662
|
+
const write = (normalizeCss, newData, image) => {
|
|
663
|
+
const oldData = read(normalizeCss, image);
|
|
664
|
+
updateProp(image, oldData, newData, 'caption', (image, _name, _value) => toggleCaption(image));
|
|
692
665
|
updateProp(image, oldData, newData, 'src', updateAttrib);
|
|
693
666
|
updateProp(image, oldData, newData, 'title', updateAttrib);
|
|
694
667
|
updateProp(image, oldData, newData, 'width', setSize('width', normalizeCss));
|
|
695
668
|
updateProp(image, oldData, newData, 'height', setSize('height', normalizeCss));
|
|
696
669
|
updateProp(image, oldData, newData, 'class', updateAttrib);
|
|
697
|
-
updateProp(image, oldData, newData, 'style', normalized(
|
|
698
|
-
return updateAttrib(image, 'style', value);
|
|
699
|
-
}, normalizeCss));
|
|
670
|
+
updateProp(image, oldData, newData, 'style', normalized((image, value) => updateAttrib(image, 'style', value), normalizeCss));
|
|
700
671
|
updateProp(image, oldData, newData, 'hspace', normalized(setHspace, normalizeCss));
|
|
701
672
|
updateProp(image, oldData, newData, 'vspace', normalized(setVspace, normalizeCss));
|
|
702
673
|
updateProp(image, oldData, newData, 'border', normalized(setBorder, normalizeCss));
|
|
@@ -704,15 +675,15 @@
|
|
|
704
675
|
updateAlt(image, oldData, newData);
|
|
705
676
|
};
|
|
706
677
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
678
|
+
const normalizeCss$1 = (editor, cssText) => {
|
|
679
|
+
const css = editor.dom.styles.parse(cssText);
|
|
680
|
+
const mergedCss = mergeMargins(css);
|
|
681
|
+
const compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss));
|
|
711
682
|
return editor.dom.styles.serialize(compressed);
|
|
712
683
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
684
|
+
const getSelectedImage = editor => {
|
|
685
|
+
const imgElm = editor.selection.getNode();
|
|
686
|
+
const figureElm = editor.dom.getParent(imgElm, 'figure.image');
|
|
716
687
|
if (figureElm) {
|
|
717
688
|
return editor.dom.select('img', figureElm)[0];
|
|
718
689
|
}
|
|
@@ -721,48 +692,41 @@
|
|
|
721
692
|
}
|
|
722
693
|
return imgElm;
|
|
723
694
|
};
|
|
724
|
-
|
|
725
|
-
var
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
var textBlock = dom.getParent(figure.parentNode, function (node) {
|
|
730
|
-
return hasNonNullableKey(textBlockElements, node.nodeName);
|
|
731
|
-
}, editor.getBody());
|
|
695
|
+
const splitTextBlock = (editor, figure) => {
|
|
696
|
+
var _a;
|
|
697
|
+
const dom = editor.dom;
|
|
698
|
+
const textBlockElements = filter(editor.schema.getTextBlockElements(), (_, parentElm) => !editor.schema.isValidChild(parentElm, 'figure'));
|
|
699
|
+
const textBlock = dom.getParent(figure.parentNode, node => hasNonNullableKey(textBlockElements, node.nodeName), editor.getBody());
|
|
732
700
|
if (textBlock) {
|
|
733
|
-
return dom.split(textBlock, figure);
|
|
701
|
+
return (_a = dom.split(textBlock, figure)) !== null && _a !== void 0 ? _a : figure;
|
|
734
702
|
} else {
|
|
735
703
|
return figure;
|
|
736
704
|
}
|
|
737
705
|
};
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return image ? read(
|
|
741
|
-
return normalizeCss$1(editor, css);
|
|
742
|
-
}, image) : defaultData();
|
|
706
|
+
const readImageDataFromSelection = editor => {
|
|
707
|
+
const image = getSelectedImage(editor);
|
|
708
|
+
return image ? read(css => normalizeCss$1(editor, css), image) : defaultData();
|
|
743
709
|
};
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
return normalizeCss$1(editor, css);
|
|
747
|
-
}, data);
|
|
710
|
+
const insertImageAtCaret = (editor, data) => {
|
|
711
|
+
const elm = create(css => normalizeCss$1(editor, css), data);
|
|
748
712
|
editor.dom.setAttrib(elm, 'data-mce-id', '__mcenew');
|
|
749
713
|
editor.focus();
|
|
750
714
|
editor.selection.setContent(elm.outerHTML);
|
|
751
|
-
|
|
715
|
+
const insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0];
|
|
752
716
|
editor.dom.setAttrib(insertedElm, 'data-mce-id', null);
|
|
753
717
|
if (isFigure(insertedElm)) {
|
|
754
|
-
|
|
718
|
+
const figure = splitTextBlock(editor, insertedElm);
|
|
755
719
|
editor.selection.select(figure);
|
|
756
720
|
} else {
|
|
757
721
|
editor.selection.select(insertedElm);
|
|
758
722
|
}
|
|
759
723
|
};
|
|
760
|
-
|
|
724
|
+
const syncSrcAttr = (editor, image) => {
|
|
761
725
|
editor.dom.setAttrib(image, 'src', image.getAttribute('src'));
|
|
762
726
|
};
|
|
763
|
-
|
|
727
|
+
const deleteImage = (editor, image) => {
|
|
764
728
|
if (image) {
|
|
765
|
-
|
|
729
|
+
const elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image;
|
|
766
730
|
editor.dom.remove(elm);
|
|
767
731
|
editor.focus();
|
|
768
732
|
editor.nodeChanged();
|
|
@@ -772,60 +736,63 @@
|
|
|
772
736
|
}
|
|
773
737
|
}
|
|
774
738
|
};
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
739
|
+
const writeImageDataToSelection = (editor, data) => {
|
|
740
|
+
const image = getSelectedImage(editor);
|
|
741
|
+
if (image) {
|
|
742
|
+
write(css => normalizeCss$1(editor, css), data, image);
|
|
743
|
+
syncSrcAttr(editor, image);
|
|
744
|
+
if (isFigure(image.parentNode)) {
|
|
745
|
+
const figure = image.parentNode;
|
|
746
|
+
splitTextBlock(editor, figure);
|
|
747
|
+
editor.selection.select(image.parentNode);
|
|
748
|
+
} else {
|
|
749
|
+
editor.selection.select(image);
|
|
750
|
+
waitLoadImage(editor, data, image);
|
|
751
|
+
}
|
|
788
752
|
}
|
|
789
753
|
};
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return
|
|
754
|
+
const sanitizeImageData = (editor, data) => {
|
|
755
|
+
const src = data.src;
|
|
756
|
+
return {
|
|
757
|
+
...data,
|
|
758
|
+
src: isSafeImageUrl(editor, src) ? src : ''
|
|
759
|
+
};
|
|
793
760
|
};
|
|
794
|
-
|
|
795
|
-
|
|
761
|
+
const insertOrUpdateImage = (editor, partialData) => {
|
|
762
|
+
const image = getSelectedImage(editor);
|
|
796
763
|
if (image) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
764
|
+
const selectedImageData = read(css => normalizeCss$1(editor, css), image);
|
|
765
|
+
const data = {
|
|
766
|
+
...selectedImageData,
|
|
767
|
+
...partialData
|
|
768
|
+
};
|
|
769
|
+
const sanitizedData = sanitizeImageData(editor, data);
|
|
802
770
|
if (data.src) {
|
|
803
771
|
writeImageDataToSelection(editor, sanitizedData);
|
|
804
772
|
} else {
|
|
805
773
|
deleteImage(editor, image);
|
|
806
774
|
}
|
|
807
775
|
} else if (partialData.src) {
|
|
808
|
-
insertImageAtCaret(editor,
|
|
776
|
+
insertImageAtCaret(editor, {
|
|
777
|
+
...defaultData(),
|
|
778
|
+
...partialData
|
|
779
|
+
});
|
|
809
780
|
}
|
|
810
781
|
};
|
|
811
782
|
|
|
812
|
-
|
|
813
|
-
|
|
783
|
+
const deep = (old, nu) => {
|
|
784
|
+
const bothObjects = isPlainObject(old) && isPlainObject(nu);
|
|
814
785
|
return bothObjects ? deepMerge(old, nu) : nu;
|
|
815
786
|
};
|
|
816
|
-
|
|
817
|
-
return
|
|
818
|
-
var objects = [];
|
|
819
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
820
|
-
objects[_i] = arguments[_i];
|
|
821
|
-
}
|
|
787
|
+
const baseMerge = merger => {
|
|
788
|
+
return (...objects) => {
|
|
822
789
|
if (objects.length === 0) {
|
|
823
|
-
throw new Error(
|
|
790
|
+
throw new Error(`Can't merge zero objects`);
|
|
824
791
|
}
|
|
825
|
-
|
|
826
|
-
for (
|
|
827
|
-
|
|
828
|
-
for (
|
|
792
|
+
const ret = {};
|
|
793
|
+
for (let j = 0; j < objects.length; j++) {
|
|
794
|
+
const curObject = objects[j];
|
|
795
|
+
for (const key in curObject) {
|
|
829
796
|
if (has(curObject, key)) {
|
|
830
797
|
ret[key] = merger(ret[key], curObject[key]);
|
|
831
798
|
}
|
|
@@ -834,20 +801,14 @@
|
|
|
834
801
|
return ret;
|
|
835
802
|
};
|
|
836
803
|
};
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
var isNotEmpty = function (s) {
|
|
840
|
-
return s.length > 0;
|
|
841
|
-
};
|
|
804
|
+
const deepMerge = baseMerge(deep);
|
|
842
805
|
|
|
843
806
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.ImageUploader');
|
|
844
807
|
|
|
845
808
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
846
809
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
};
|
|
850
|
-
var getText = function (item) {
|
|
810
|
+
const getValue = item => isString(item.value) ? item.value : '';
|
|
811
|
+
const getText = item => {
|
|
851
812
|
if (isString(item.text)) {
|
|
852
813
|
return item.text;
|
|
853
814
|
} else if (isString(item.title)) {
|
|
@@ -856,241 +817,206 @@
|
|
|
856
817
|
return '';
|
|
857
818
|
}
|
|
858
819
|
};
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
global.each(list,
|
|
862
|
-
|
|
820
|
+
const sanitizeList = (list, extractValue) => {
|
|
821
|
+
const out = [];
|
|
822
|
+
global.each(list, item => {
|
|
823
|
+
const text = getText(item);
|
|
863
824
|
if (item.menu !== undefined) {
|
|
864
|
-
|
|
825
|
+
const items = sanitizeList(item.menu, extractValue);
|
|
865
826
|
out.push({
|
|
866
|
-
text
|
|
867
|
-
items
|
|
827
|
+
text,
|
|
828
|
+
items
|
|
868
829
|
});
|
|
869
830
|
} else {
|
|
870
|
-
|
|
831
|
+
const value = extractValue(item);
|
|
871
832
|
out.push({
|
|
872
|
-
text
|
|
873
|
-
value
|
|
833
|
+
text,
|
|
834
|
+
value
|
|
874
835
|
});
|
|
875
836
|
}
|
|
876
837
|
});
|
|
877
838
|
return out;
|
|
878
839
|
};
|
|
879
|
-
|
|
880
|
-
if (
|
|
881
|
-
|
|
840
|
+
const sanitizer = (extractor = getValue) => list => {
|
|
841
|
+
if (list) {
|
|
842
|
+
return Optional.from(list).map(list => sanitizeList(list, extractor));
|
|
843
|
+
} else {
|
|
844
|
+
return Optional.none();
|
|
882
845
|
}
|
|
883
|
-
return function (list) {
|
|
884
|
-
if (list) {
|
|
885
|
-
return Optional.from(list).map(function (list) {
|
|
886
|
-
return sanitizeList(list, extractor);
|
|
887
|
-
});
|
|
888
|
-
} else {
|
|
889
|
-
return Optional.none();
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
846
|
};
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
};
|
|
910
|
-
var findEntry = function (optList, value) {
|
|
911
|
-
return optList.bind(function (list) {
|
|
912
|
-
return findEntryDelegate(list, value);
|
|
913
|
-
});
|
|
914
|
-
};
|
|
915
|
-
var ListUtils = {
|
|
916
|
-
sanitizer: sanitizer,
|
|
917
|
-
sanitize: sanitize,
|
|
918
|
-
findEntry: findEntry
|
|
919
|
-
};
|
|
920
|
-
|
|
921
|
-
var makeTab$2 = function (_info) {
|
|
922
|
-
return {
|
|
923
|
-
title: 'Advanced',
|
|
924
|
-
name: 'advanced',
|
|
925
|
-
items: [
|
|
926
|
-
{
|
|
927
|
-
type: 'input',
|
|
928
|
-
label: 'Style',
|
|
929
|
-
name: 'style'
|
|
930
|
-
},
|
|
931
|
-
{
|
|
932
|
-
type: 'grid',
|
|
933
|
-
columns: 2,
|
|
934
|
-
items: [
|
|
935
|
-
{
|
|
936
|
-
type: 'input',
|
|
937
|
-
label: 'Vertical space',
|
|
938
|
-
name: 'vspace',
|
|
939
|
-
inputMode: 'numeric'
|
|
940
|
-
},
|
|
941
|
-
{
|
|
942
|
-
type: 'input',
|
|
943
|
-
label: 'Horizontal space',
|
|
944
|
-
name: 'hspace',
|
|
945
|
-
inputMode: 'numeric'
|
|
946
|
-
},
|
|
947
|
-
{
|
|
948
|
-
type: 'input',
|
|
949
|
-
label: 'Border width',
|
|
950
|
-
name: 'border',
|
|
951
|
-
inputMode: 'numeric'
|
|
952
|
-
},
|
|
953
|
-
{
|
|
954
|
-
type: 'listbox',
|
|
955
|
-
name: 'borderstyle',
|
|
956
|
-
label: 'Border style',
|
|
957
|
-
items: [
|
|
958
|
-
{
|
|
959
|
-
text: 'Select...',
|
|
960
|
-
value: ''
|
|
961
|
-
},
|
|
962
|
-
{
|
|
963
|
-
text: 'Solid',
|
|
964
|
-
value: 'solid'
|
|
965
|
-
},
|
|
966
|
-
{
|
|
967
|
-
text: 'Dotted',
|
|
968
|
-
value: 'dotted'
|
|
969
|
-
},
|
|
970
|
-
{
|
|
971
|
-
text: 'Dashed',
|
|
972
|
-
value: 'dashed'
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
text: 'Double',
|
|
976
|
-
value: 'double'
|
|
977
|
-
},
|
|
978
|
-
{
|
|
979
|
-
text: 'Groove',
|
|
980
|
-
value: 'groove'
|
|
981
|
-
},
|
|
982
|
-
{
|
|
983
|
-
text: 'Ridge',
|
|
984
|
-
value: 'ridge'
|
|
985
|
-
},
|
|
986
|
-
{
|
|
987
|
-
text: 'Inset',
|
|
988
|
-
value: 'inset'
|
|
989
|
-
},
|
|
990
|
-
{
|
|
991
|
-
text: 'Outset',
|
|
992
|
-
value: 'outset'
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
text: 'None',
|
|
996
|
-
value: 'none'
|
|
997
|
-
},
|
|
998
|
-
{
|
|
999
|
-
text: 'Hidden',
|
|
1000
|
-
value: 'hidden'
|
|
1001
|
-
}
|
|
1002
|
-
]
|
|
1003
|
-
}
|
|
1004
|
-
]
|
|
1005
|
-
}
|
|
1006
|
-
]
|
|
1007
|
-
};
|
|
847
|
+
const sanitize = list => sanitizer(getValue)(list);
|
|
848
|
+
const isGroup = item => has(item, 'items');
|
|
849
|
+
const findEntryDelegate = (list, value) => findMap(list, item => {
|
|
850
|
+
if (isGroup(item)) {
|
|
851
|
+
return findEntryDelegate(item.items, value);
|
|
852
|
+
} else if (item.value === value) {
|
|
853
|
+
return Optional.some(item);
|
|
854
|
+
} else {
|
|
855
|
+
return Optional.none();
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
const findEntry = (optList, value) => optList.bind(list => findEntryDelegate(list, value));
|
|
859
|
+
const ListUtils = {
|
|
860
|
+
sanitizer,
|
|
861
|
+
sanitize,
|
|
862
|
+
findEntry
|
|
1008
863
|
};
|
|
1009
|
-
var AdvTab = { makeTab: makeTab$2 };
|
|
1010
864
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
865
|
+
const makeTab$2 = _info => ({
|
|
866
|
+
title: 'Advanced',
|
|
867
|
+
name: 'advanced',
|
|
868
|
+
items: [{
|
|
869
|
+
type: 'grid',
|
|
870
|
+
columns: 2,
|
|
871
|
+
items: [
|
|
872
|
+
{
|
|
873
|
+
type: 'input',
|
|
874
|
+
label: 'Vertical space',
|
|
875
|
+
name: 'vspace',
|
|
876
|
+
inputMode: 'numeric'
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
type: 'input',
|
|
880
|
+
label: 'Horizontal space',
|
|
881
|
+
name: 'hspace',
|
|
882
|
+
inputMode: 'numeric'
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
type: 'input',
|
|
886
|
+
label: 'Border width',
|
|
887
|
+
name: 'border',
|
|
888
|
+
inputMode: 'numeric'
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
type: 'listbox',
|
|
892
|
+
name: 'borderstyle',
|
|
893
|
+
label: 'Border style',
|
|
894
|
+
items: [
|
|
895
|
+
{
|
|
896
|
+
text: 'Select...',
|
|
1021
897
|
value: ''
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
text: 'Solid',
|
|
901
|
+
value: 'solid'
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
text: 'Dotted',
|
|
905
|
+
value: 'dotted'
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
text: 'Dashed',
|
|
909
|
+
value: 'dashed'
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
text: 'Double',
|
|
913
|
+
value: 'double'
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
text: 'Groove',
|
|
917
|
+
value: 'groove'
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
text: 'Ridge',
|
|
921
|
+
value: 'ridge'
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
text: 'Inset',
|
|
925
|
+
value: 'inset'
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
text: 'Outset',
|
|
929
|
+
value: 'outset'
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
text: 'None',
|
|
933
|
+
value: 'none'
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
text: 'Hidden',
|
|
937
|
+
value: 'hidden'
|
|
938
|
+
}
|
|
939
|
+
]
|
|
940
|
+
}
|
|
941
|
+
]
|
|
942
|
+
}]
|
|
943
|
+
});
|
|
944
|
+
const AdvTab = { makeTab: makeTab$2 };
|
|
945
|
+
|
|
946
|
+
const collect = editor => {
|
|
947
|
+
const urlListSanitizer = ListUtils.sanitizer(item => editor.convertURL(item.value || item.url || '', 'src'));
|
|
948
|
+
const futureImageList = new Promise(completer => {
|
|
949
|
+
createImageList(editor, imageList => {
|
|
950
|
+
completer(urlListSanitizer(imageList).map(items => flatten([
|
|
951
|
+
[{
|
|
952
|
+
text: 'None',
|
|
953
|
+
value: ''
|
|
954
|
+
}],
|
|
955
|
+
items
|
|
956
|
+
])));
|
|
1026
957
|
});
|
|
1027
958
|
});
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
hasAccessibilityOptions: hasAccessibilityOptions,
|
|
1058
|
-
automaticUploads: automaticUploads
|
|
1059
|
-
};
|
|
1060
|
-
});
|
|
959
|
+
const classList = ListUtils.sanitize(getClassList(editor));
|
|
960
|
+
const hasAdvTab$1 = hasAdvTab(editor);
|
|
961
|
+
const hasUploadTab$1 = hasUploadTab(editor);
|
|
962
|
+
const hasUploadUrl$1 = hasUploadUrl(editor);
|
|
963
|
+
const hasUploadHandler$1 = hasUploadHandler(editor);
|
|
964
|
+
const image = readImageDataFromSelection(editor);
|
|
965
|
+
const hasDescription$1 = hasDescription(editor);
|
|
966
|
+
const hasImageTitle$1 = hasImageTitle(editor);
|
|
967
|
+
const hasDimensions$1 = hasDimensions(editor);
|
|
968
|
+
const hasImageCaption$1 = hasImageCaption(editor);
|
|
969
|
+
const hasAccessibilityOptions = showAccessibilityOptions(editor);
|
|
970
|
+
const automaticUploads = isAutomaticUploadsEnabled(editor);
|
|
971
|
+
const prependURL = Optional.some(getPrependUrl(editor)).filter(preUrl => isString(preUrl) && preUrl.length > 0);
|
|
972
|
+
return futureImageList.then(imageList => ({
|
|
973
|
+
image,
|
|
974
|
+
imageList,
|
|
975
|
+
classList,
|
|
976
|
+
hasAdvTab: hasAdvTab$1,
|
|
977
|
+
hasUploadTab: hasUploadTab$1,
|
|
978
|
+
hasUploadUrl: hasUploadUrl$1,
|
|
979
|
+
hasUploadHandler: hasUploadHandler$1,
|
|
980
|
+
hasDescription: hasDescription$1,
|
|
981
|
+
hasImageTitle: hasImageTitle$1,
|
|
982
|
+
hasDimensions: hasDimensions$1,
|
|
983
|
+
hasImageCaption: hasImageCaption$1,
|
|
984
|
+
prependURL,
|
|
985
|
+
hasAccessibilityOptions,
|
|
986
|
+
automaticUploads
|
|
987
|
+
}));
|
|
1061
988
|
};
|
|
1062
989
|
|
|
1063
|
-
|
|
1064
|
-
|
|
990
|
+
const makeItems = info => {
|
|
991
|
+
const imageUrl = {
|
|
1065
992
|
name: 'src',
|
|
1066
993
|
type: 'urlinput',
|
|
1067
994
|
filetype: 'image',
|
|
1068
|
-
label: 'Source'
|
|
995
|
+
label: 'Source',
|
|
996
|
+
picker_text: 'Browse files'
|
|
1069
997
|
};
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
});
|
|
1078
|
-
var imageDescription = {
|
|
998
|
+
const imageList = info.imageList.map(items => ({
|
|
999
|
+
name: 'images',
|
|
1000
|
+
type: 'listbox',
|
|
1001
|
+
label: 'Image list',
|
|
1002
|
+
items
|
|
1003
|
+
}));
|
|
1004
|
+
const imageDescription = {
|
|
1079
1005
|
name: 'alt',
|
|
1080
1006
|
type: 'input',
|
|
1081
1007
|
label: 'Alternative description',
|
|
1082
|
-
|
|
1008
|
+
enabled: !(info.hasAccessibilityOptions && info.image.isDecorative)
|
|
1083
1009
|
};
|
|
1084
|
-
|
|
1010
|
+
const imageTitle = {
|
|
1085
1011
|
name: 'title',
|
|
1086
1012
|
type: 'input',
|
|
1087
1013
|
label: 'Image title'
|
|
1088
1014
|
};
|
|
1089
|
-
|
|
1015
|
+
const imageDimensions = {
|
|
1090
1016
|
name: 'dimensions',
|
|
1091
1017
|
type: 'sizeinput'
|
|
1092
1018
|
};
|
|
1093
|
-
|
|
1019
|
+
const isDecorative = {
|
|
1094
1020
|
type: 'label',
|
|
1095
1021
|
label: 'Accessibility',
|
|
1096
1022
|
items: [{
|
|
@@ -1099,15 +1025,13 @@
|
|
|
1099
1025
|
label: 'Image is decorative'
|
|
1100
1026
|
}]
|
|
1101
1027
|
};
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
});
|
|
1110
|
-
var caption = {
|
|
1028
|
+
const classList = info.classList.map(items => ({
|
|
1029
|
+
name: 'classes',
|
|
1030
|
+
type: 'listbox',
|
|
1031
|
+
label: 'Class',
|
|
1032
|
+
items
|
|
1033
|
+
}));
|
|
1034
|
+
const caption = {
|
|
1111
1035
|
type: 'label',
|
|
1112
1036
|
label: 'Caption',
|
|
1113
1037
|
items: [{
|
|
@@ -1116,12 +1040,10 @@
|
|
|
1116
1040
|
label: 'Show caption'
|
|
1117
1041
|
}]
|
|
1118
1042
|
};
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
} : { type: 'panel' };
|
|
1124
|
-
};
|
|
1043
|
+
const getDialogContainerType = useColumns => useColumns ? {
|
|
1044
|
+
type: 'grid',
|
|
1045
|
+
columns: 2
|
|
1046
|
+
} : { type: 'panel' };
|
|
1125
1047
|
return flatten([
|
|
1126
1048
|
[imageUrl],
|
|
1127
1049
|
imageList.toArray(),
|
|
@@ -1129,90 +1051,83 @@
|
|
|
1129
1051
|
info.hasDescription ? [imageDescription] : [],
|
|
1130
1052
|
info.hasImageTitle ? [imageTitle] : [],
|
|
1131
1053
|
info.hasDimensions ? [imageDimensions] : [],
|
|
1132
|
-
[
|
|
1054
|
+
[{
|
|
1055
|
+
...getDialogContainerType(info.classList.isSome() && info.hasImageCaption),
|
|
1133
1056
|
items: flatten([
|
|
1134
1057
|
classList.toArray(),
|
|
1135
1058
|
info.hasImageCaption ? [caption] : []
|
|
1136
1059
|
])
|
|
1137
|
-
}
|
|
1060
|
+
}]
|
|
1138
1061
|
]);
|
|
1139
1062
|
};
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
};
|
|
1147
|
-
var MainTab = {
|
|
1063
|
+
const makeTab$1 = info => ({
|
|
1064
|
+
title: 'General',
|
|
1065
|
+
name: 'general',
|
|
1066
|
+
items: makeItems(info)
|
|
1067
|
+
});
|
|
1068
|
+
const MainTab = {
|
|
1148
1069
|
makeTab: makeTab$1,
|
|
1149
|
-
makeItems
|
|
1070
|
+
makeItems
|
|
1150
1071
|
};
|
|
1151
1072
|
|
|
1152
|
-
|
|
1153
|
-
|
|
1073
|
+
const makeTab = _info => {
|
|
1074
|
+
const items = [{
|
|
1154
1075
|
type: 'dropzone',
|
|
1155
1076
|
name: 'fileinput'
|
|
1156
1077
|
}];
|
|
1157
1078
|
return {
|
|
1158
1079
|
title: 'Upload',
|
|
1159
1080
|
name: 'upload',
|
|
1160
|
-
items
|
|
1081
|
+
items
|
|
1161
1082
|
};
|
|
1162
1083
|
};
|
|
1163
|
-
|
|
1084
|
+
const UploadTab = { makeTab };
|
|
1164
1085
|
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
border: data.border,
|
|
1209
|
-
borderStyle: data.borderstyle,
|
|
1210
|
-
isDecorative: data.isDecorative
|
|
1211
|
-
};
|
|
1212
|
-
};
|
|
1213
|
-
var addPrependUrl2 = function (info, srcURL) {
|
|
1086
|
+
const createState = info => ({
|
|
1087
|
+
prevImage: ListUtils.findEntry(info.imageList, info.image.src),
|
|
1088
|
+
prevAlt: info.image.alt,
|
|
1089
|
+
open: true
|
|
1090
|
+
});
|
|
1091
|
+
const fromImageData = image => ({
|
|
1092
|
+
src: {
|
|
1093
|
+
value: image.src,
|
|
1094
|
+
meta: {}
|
|
1095
|
+
},
|
|
1096
|
+
images: image.src,
|
|
1097
|
+
alt: image.alt,
|
|
1098
|
+
title: image.title,
|
|
1099
|
+
dimensions: {
|
|
1100
|
+
width: image.width,
|
|
1101
|
+
height: image.height
|
|
1102
|
+
},
|
|
1103
|
+
classes: image.class,
|
|
1104
|
+
caption: image.caption,
|
|
1105
|
+
style: image.style,
|
|
1106
|
+
vspace: image.vspace,
|
|
1107
|
+
border: image.border,
|
|
1108
|
+
hspace: image.hspace,
|
|
1109
|
+
borderstyle: image.borderStyle,
|
|
1110
|
+
fileinput: [],
|
|
1111
|
+
isDecorative: image.isDecorative
|
|
1112
|
+
});
|
|
1113
|
+
const toImageData = (data, removeEmptyAlt) => ({
|
|
1114
|
+
src: data.src.value,
|
|
1115
|
+
alt: (data.alt === null || data.alt.length === 0) && removeEmptyAlt ? null : data.alt,
|
|
1116
|
+
title: data.title,
|
|
1117
|
+
width: data.dimensions.width,
|
|
1118
|
+
height: data.dimensions.height,
|
|
1119
|
+
class: data.classes,
|
|
1120
|
+
style: data.style,
|
|
1121
|
+
caption: data.caption,
|
|
1122
|
+
hspace: data.hspace,
|
|
1123
|
+
vspace: data.vspace,
|
|
1124
|
+
border: data.border,
|
|
1125
|
+
borderStyle: data.borderstyle,
|
|
1126
|
+
isDecorative: data.isDecorative
|
|
1127
|
+
});
|
|
1128
|
+
const addPrependUrl2 = (info, srcURL) => {
|
|
1214
1129
|
if (!/^(?:[a-zA-Z]+:)?\/\//.test(srcURL)) {
|
|
1215
|
-
return info.prependURL.bind(
|
|
1130
|
+
return info.prependURL.bind(prependUrl => {
|
|
1216
1131
|
if (srcURL.substring(0, prependUrl.length) !== prependUrl) {
|
|
1217
1132
|
return Optional.some(prependUrl + srcURL);
|
|
1218
1133
|
}
|
|
@@ -1221,9 +1136,9 @@
|
|
|
1221
1136
|
}
|
|
1222
1137
|
return Optional.none();
|
|
1223
1138
|
};
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
addPrependUrl2(info, data.src.value).each(
|
|
1139
|
+
const addPrependUrl = (info, api) => {
|
|
1140
|
+
const data = api.getData();
|
|
1141
|
+
addPrependUrl2(info, data.src.value).each(srcURL => {
|
|
1227
1142
|
api.setData({
|
|
1228
1143
|
src: {
|
|
1229
1144
|
value: srcURL,
|
|
@@ -1232,7 +1147,7 @@
|
|
|
1232
1147
|
});
|
|
1233
1148
|
});
|
|
1234
1149
|
};
|
|
1235
|
-
|
|
1150
|
+
const formFillFromMeta2 = (info, data, meta) => {
|
|
1236
1151
|
if (info.hasDescription && isString(meta.alt)) {
|
|
1237
1152
|
data.alt = meta.alt;
|
|
1238
1153
|
}
|
|
@@ -1251,7 +1166,7 @@
|
|
|
1251
1166
|
}
|
|
1252
1167
|
}
|
|
1253
1168
|
if (isString(meta.class)) {
|
|
1254
|
-
ListUtils.findEntry(info.classList, meta.class).each(
|
|
1169
|
+
ListUtils.findEntry(info.classList, meta.class).each(entry => {
|
|
1255
1170
|
data.classes = entry.value;
|
|
1256
1171
|
});
|
|
1257
1172
|
}
|
|
@@ -1278,28 +1193,26 @@
|
|
|
1278
1193
|
}
|
|
1279
1194
|
}
|
|
1280
1195
|
};
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1196
|
+
const formFillFromMeta = (info, api) => {
|
|
1197
|
+
const data = api.getData();
|
|
1198
|
+
const meta = data.src.meta;
|
|
1284
1199
|
if (meta !== undefined) {
|
|
1285
|
-
|
|
1200
|
+
const newData = deepMerge({}, data);
|
|
1286
1201
|
formFillFromMeta2(info, newData, meta);
|
|
1287
1202
|
api.setData(newData);
|
|
1288
1203
|
}
|
|
1289
1204
|
};
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1205
|
+
const calculateImageSize = (helpers, info, state, api) => {
|
|
1206
|
+
const data = api.getData();
|
|
1207
|
+
const url = data.src.value;
|
|
1208
|
+
const meta = data.src.meta || {};
|
|
1294
1209
|
if (!meta.width && !meta.height && info.hasDimensions) {
|
|
1295
1210
|
if (isNotEmpty(url)) {
|
|
1296
|
-
helpers.imageSize(url).then(
|
|
1211
|
+
helpers.imageSize(url).then(size => {
|
|
1297
1212
|
if (state.open) {
|
|
1298
1213
|
api.setData({ dimensions: size });
|
|
1299
1214
|
}
|
|
1300
|
-
}).catch(
|
|
1301
|
-
return console.error(e);
|
|
1302
|
-
});
|
|
1215
|
+
}).catch(e => console.error(e));
|
|
1303
1216
|
} else {
|
|
1304
1217
|
api.setData({
|
|
1305
1218
|
dimensions: {
|
|
@@ -1310,29 +1223,23 @@
|
|
|
1310
1223
|
}
|
|
1311
1224
|
}
|
|
1312
1225
|
};
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1226
|
+
const updateImagesDropdown = (info, state, api) => {
|
|
1227
|
+
const data = api.getData();
|
|
1228
|
+
const image = ListUtils.findEntry(info.imageList, data.src.value);
|
|
1316
1229
|
state.prevImage = image;
|
|
1317
|
-
api.setData({
|
|
1318
|
-
images: image.map(function (entry) {
|
|
1319
|
-
return entry.value;
|
|
1320
|
-
}).getOr('')
|
|
1321
|
-
});
|
|
1230
|
+
api.setData({ images: image.map(entry => entry.value).getOr('') });
|
|
1322
1231
|
};
|
|
1323
|
-
|
|
1232
|
+
const changeSrc = (helpers, info, state, api) => {
|
|
1324
1233
|
addPrependUrl(info, api);
|
|
1325
1234
|
formFillFromMeta(info, api);
|
|
1326
1235
|
calculateImageSize(helpers, info, state, api);
|
|
1327
1236
|
updateImagesDropdown(info, state, api);
|
|
1328
1237
|
};
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
image.each(
|
|
1333
|
-
|
|
1334
|
-
return image.text === data.alt;
|
|
1335
|
-
}).getOr(false);
|
|
1238
|
+
const changeImages = (helpers, info, state, api) => {
|
|
1239
|
+
const data = api.getData();
|
|
1240
|
+
const image = ListUtils.findEntry(info.imageList, data.images);
|
|
1241
|
+
image.each(img => {
|
|
1242
|
+
const updateAlt = data.alt === '' || state.prevImage.map(image => image.text === data.alt).getOr(false);
|
|
1336
1243
|
if (updateAlt) {
|
|
1337
1244
|
if (img.value === '') {
|
|
1338
1245
|
api.setData({
|
|
@@ -1352,55 +1259,18 @@
|
|
|
1352
1259
|
state.prevImage = image;
|
|
1353
1260
|
changeSrc(helpers, info, state, api);
|
|
1354
1261
|
};
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
return matchingTopBottom ? removePixelSuffix(String(css['margin-top'])) : '';
|
|
1358
|
-
};
|
|
1359
|
-
var calcHSpace = function (css) {
|
|
1360
|
-
var matchingLeftRight = css['margin-right'] && css['margin-left'] && css['margin-right'] === css['margin-left'];
|
|
1361
|
-
return matchingLeftRight ? removePixelSuffix(String(css['margin-right'])) : '';
|
|
1362
|
-
};
|
|
1363
|
-
var calcBorderWidth = function (css) {
|
|
1364
|
-
return css['border-width'] ? removePixelSuffix(String(css['border-width'])) : '';
|
|
1365
|
-
};
|
|
1366
|
-
var calcBorderStyle = function (css) {
|
|
1367
|
-
return css['border-style'] ? String(css['border-style']) : '';
|
|
1368
|
-
};
|
|
1369
|
-
var calcStyle = function (parseStyle, serializeStyle, css) {
|
|
1370
|
-
return serializeStyle(parseStyle(serializeStyle(css)));
|
|
1371
|
-
};
|
|
1372
|
-
var changeStyle2 = function (parseStyle, serializeStyle, data) {
|
|
1373
|
-
var css = mergeMargins(parseStyle(data.style));
|
|
1374
|
-
var dataCopy = deepMerge({}, data);
|
|
1375
|
-
dataCopy.vspace = calcVSpace(css);
|
|
1376
|
-
dataCopy.hspace = calcHSpace(css);
|
|
1377
|
-
dataCopy.border = calcBorderWidth(css);
|
|
1378
|
-
dataCopy.borderstyle = calcBorderStyle(css);
|
|
1379
|
-
dataCopy.style = calcStyle(parseStyle, serializeStyle, css);
|
|
1380
|
-
return dataCopy;
|
|
1381
|
-
};
|
|
1382
|
-
var changeStyle = function (helpers, api) {
|
|
1383
|
-
var data = api.getData();
|
|
1384
|
-
var newData = changeStyle2(helpers.parseStyle, helpers.serializeStyle, data);
|
|
1385
|
-
api.setData(newData);
|
|
1386
|
-
};
|
|
1387
|
-
var changeAStyle = function (helpers, info, api) {
|
|
1388
|
-
var data = deepMerge(fromImageData(info.image), api.getData());
|
|
1389
|
-
var style = getStyleValue(helpers.normalizeCss, toImageData(data, false));
|
|
1390
|
-
api.setData({ style: style });
|
|
1391
|
-
};
|
|
1392
|
-
var changeFileInput = function (helpers, info, state, api) {
|
|
1393
|
-
var data = api.getData();
|
|
1262
|
+
const changeFileInput = (helpers, info, state, api) => {
|
|
1263
|
+
const data = api.getData();
|
|
1394
1264
|
api.block('Uploading image');
|
|
1395
|
-
head(data.fileinput).fold(
|
|
1265
|
+
head(data.fileinput).fold(() => {
|
|
1396
1266
|
api.unblock();
|
|
1397
|
-
},
|
|
1398
|
-
|
|
1399
|
-
|
|
1267
|
+
}, file => {
|
|
1268
|
+
const blobUri = URL.createObjectURL(file);
|
|
1269
|
+
const finalize = () => {
|
|
1400
1270
|
api.unblock();
|
|
1401
1271
|
URL.revokeObjectURL(blobUri);
|
|
1402
1272
|
};
|
|
1403
|
-
|
|
1273
|
+
const updateSrcAndSwitchTab = url => {
|
|
1404
1274
|
api.setData({
|
|
1405
1275
|
src: {
|
|
1406
1276
|
value: url,
|
|
@@ -1410,13 +1280,13 @@
|
|
|
1410
1280
|
api.showTab('general');
|
|
1411
1281
|
changeSrc(helpers, info, state, api);
|
|
1412
1282
|
};
|
|
1413
|
-
blobToDataUri(file).then(
|
|
1414
|
-
|
|
1283
|
+
blobToDataUri(file).then(dataUrl => {
|
|
1284
|
+
const blobInfo = helpers.createBlobCache(file, blobUri, dataUrl);
|
|
1415
1285
|
if (info.automaticUploads) {
|
|
1416
|
-
helpers.uploadImage(blobInfo).then(
|
|
1286
|
+
helpers.uploadImage(blobInfo).then(result => {
|
|
1417
1287
|
updateSrcAndSwitchTab(result.url);
|
|
1418
1288
|
finalize();
|
|
1419
|
-
}).catch(
|
|
1289
|
+
}).catch(err => {
|
|
1420
1290
|
finalize();
|
|
1421
1291
|
helpers.alertErr(err);
|
|
1422
1292
|
});
|
|
@@ -1428,37 +1298,25 @@
|
|
|
1428
1298
|
});
|
|
1429
1299
|
});
|
|
1430
1300
|
};
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
} else if (evt.name === 'fileinput') {
|
|
1444
|
-
changeFileInput(helpers, info, state, api);
|
|
1445
|
-
} else if (evt.name === 'isDecorative') {
|
|
1446
|
-
if (api.getData().isDecorative) {
|
|
1447
|
-
api.disable('alt');
|
|
1448
|
-
} else {
|
|
1449
|
-
api.enable('alt');
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
};
|
|
1301
|
+
const changeHandler = (helpers, info, state) => (api, evt) => {
|
|
1302
|
+
if (evt.name === 'src') {
|
|
1303
|
+
changeSrc(helpers, info, state, api);
|
|
1304
|
+
} else if (evt.name === 'images') {
|
|
1305
|
+
changeImages(helpers, info, state, api);
|
|
1306
|
+
} else if (evt.name === 'alt') {
|
|
1307
|
+
state.prevAlt = api.getData().alt;
|
|
1308
|
+
} else if (evt.name === 'fileinput') {
|
|
1309
|
+
changeFileInput(helpers, info, state, api);
|
|
1310
|
+
} else if (evt.name === 'isDecorative') {
|
|
1311
|
+
api.setEnabled('alt', !api.getData().isDecorative);
|
|
1312
|
+
}
|
|
1453
1313
|
};
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
state.open = false;
|
|
1457
|
-
};
|
|
1314
|
+
const closeHandler = state => () => {
|
|
1315
|
+
state.open = false;
|
|
1458
1316
|
};
|
|
1459
|
-
|
|
1317
|
+
const makeDialogBody = info => {
|
|
1460
1318
|
if (info.hasAdvTab || info.hasUploadUrl || info.hasUploadHandler) {
|
|
1461
|
-
|
|
1319
|
+
const tabPanel = {
|
|
1462
1320
|
type: 'tabpanel',
|
|
1463
1321
|
tabs: flatten([
|
|
1464
1322
|
[MainTab.makeTab(info)],
|
|
@@ -1468,119 +1326,67 @@
|
|
|
1468
1326
|
};
|
|
1469
1327
|
return tabPanel;
|
|
1470
1328
|
} else {
|
|
1471
|
-
|
|
1329
|
+
const panel = {
|
|
1472
1330
|
type: 'panel',
|
|
1473
1331
|
items: MainTab.makeItems(info)
|
|
1474
1332
|
};
|
|
1475
1333
|
return panel;
|
|
1476
1334
|
}
|
|
1477
1335
|
};
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
size: 'normal',
|
|
1484
|
-
body: makeDialogBody(info),
|
|
1485
|
-
buttons: [
|
|
1486
|
-
{
|
|
1487
|
-
type: 'cancel',
|
|
1488
|
-
name: 'cancel',
|
|
1489
|
-
text: 'Cancel'
|
|
1490
|
-
},
|
|
1491
|
-
{
|
|
1492
|
-
type: 'submit',
|
|
1493
|
-
name: 'save',
|
|
1494
|
-
text: 'Save',
|
|
1495
|
-
primary: true
|
|
1496
|
-
}
|
|
1497
|
-
],
|
|
1498
|
-
initialData: fromImageData(info.image),
|
|
1499
|
-
onSubmit: helpers.onSubmit(info),
|
|
1500
|
-
onChange: changeHandler(helpers, info, state),
|
|
1501
|
-
onClose: closeHandler(state)
|
|
1502
|
-
};
|
|
1503
|
-
};
|
|
1504
|
-
};
|
|
1505
|
-
var submitHandler = function (editor) {
|
|
1506
|
-
return function (info) {
|
|
1507
|
-
return function (api) {
|
|
1508
|
-
var data = deepMerge(fromImageData(info.image), api.getData());
|
|
1509
|
-
editor.execCommand('mceUpdateImage', false, toImageData(data, info.hasAccessibilityOptions));
|
|
1510
|
-
editor.editorUpload.uploadImagesAuto();
|
|
1511
|
-
api.close();
|
|
1512
|
-
};
|
|
1513
|
-
};
|
|
1514
|
-
};
|
|
1515
|
-
var imageSize = function (editor) {
|
|
1516
|
-
return function (url) {
|
|
1517
|
-
if (!isSafeImageUrl(editor, url)) {
|
|
1518
|
-
return global$4.resolve({
|
|
1519
|
-
width: '',
|
|
1520
|
-
height: ''
|
|
1521
|
-
});
|
|
1522
|
-
} else {
|
|
1523
|
-
return getImageSize(editor.documentBaseURI.toAbsolute(url)).then(function (dimensions) {
|
|
1524
|
-
return {
|
|
1525
|
-
width: String(dimensions.width),
|
|
1526
|
-
height: String(dimensions.height)
|
|
1527
|
-
};
|
|
1528
|
-
});
|
|
1529
|
-
}
|
|
1336
|
+
const submitHandler = (editor, info, helpers) => api => {
|
|
1337
|
+
const data = deepMerge(fromImageData(info.image), api.getData());
|
|
1338
|
+
const finalData = {
|
|
1339
|
+
...data,
|
|
1340
|
+
style: getStyleValue(helpers.normalizeCss, toImageData(data, false))
|
|
1530
1341
|
};
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1342
|
+
editor.execCommand('mceUpdateImage', false, toImageData(finalData, info.hasAccessibilityOptions));
|
|
1343
|
+
editor.editorUpload.uploadImagesAuto();
|
|
1344
|
+
api.close();
|
|
1345
|
+
};
|
|
1346
|
+
const imageSize = editor => url => {
|
|
1347
|
+
if (!isSafeImageUrl(editor, url)) {
|
|
1348
|
+
return Promise.resolve({
|
|
1349
|
+
width: '',
|
|
1350
|
+
height: ''
|
|
1540
1351
|
});
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
}
|
|
1547
|
-
};
|
|
1548
|
-
var alertErr = function (editor) {
|
|
1549
|
-
return function (message) {
|
|
1550
|
-
editor.windowManager.alert(message);
|
|
1551
|
-
};
|
|
1552
|
-
};
|
|
1553
|
-
var normalizeCss = function (editor) {
|
|
1554
|
-
return function (cssText) {
|
|
1555
|
-
return normalizeCss$1(editor, cssText);
|
|
1556
|
-
};
|
|
1557
|
-
};
|
|
1558
|
-
var parseStyle = function (editor) {
|
|
1559
|
-
return function (cssText) {
|
|
1560
|
-
return editor.dom.parseStyle(cssText);
|
|
1561
|
-
};
|
|
1562
|
-
};
|
|
1563
|
-
var serializeStyle = function (editor) {
|
|
1564
|
-
return function (stylesArg, name) {
|
|
1565
|
-
return editor.dom.serializeStyle(stylesArg, name);
|
|
1566
|
-
};
|
|
1352
|
+
} else {
|
|
1353
|
+
return getImageSize(editor.documentBaseURI.toAbsolute(url)).then(dimensions => ({
|
|
1354
|
+
width: String(dimensions.width),
|
|
1355
|
+
height: String(dimensions.height)
|
|
1356
|
+
}));
|
|
1357
|
+
}
|
|
1567
1358
|
};
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
}
|
|
1578
|
-
});
|
|
1579
|
-
};
|
|
1359
|
+
const createBlobCache = editor => (file, blobUri, dataUrl) => {
|
|
1360
|
+
var _a;
|
|
1361
|
+
return editor.editorUpload.blobCache.create({
|
|
1362
|
+
blob: file,
|
|
1363
|
+
blobUri,
|
|
1364
|
+
name: (_a = file.name) === null || _a === void 0 ? void 0 : _a.replace(/\.[^\.]+$/, ''),
|
|
1365
|
+
filename: file.name,
|
|
1366
|
+
base64: dataUrl.split(',')[1]
|
|
1367
|
+
});
|
|
1580
1368
|
};
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1369
|
+
const addToBlobCache = editor => blobInfo => {
|
|
1370
|
+
editor.editorUpload.blobCache.add(blobInfo);
|
|
1371
|
+
};
|
|
1372
|
+
const alertErr = editor => message => {
|
|
1373
|
+
editor.windowManager.alert(message);
|
|
1374
|
+
};
|
|
1375
|
+
const normalizeCss = editor => cssText => normalizeCss$1(editor, cssText);
|
|
1376
|
+
const parseStyle = editor => cssText => editor.dom.parseStyle(cssText);
|
|
1377
|
+
const serializeStyle = editor => (stylesArg, name) => editor.dom.serializeStyle(stylesArg, name);
|
|
1378
|
+
const uploadImage = editor => blobInfo => global$1(editor).upload([blobInfo], false).then(results => {
|
|
1379
|
+
var _a;
|
|
1380
|
+
if (results.length === 0) {
|
|
1381
|
+
return Promise.reject('Failed to upload image');
|
|
1382
|
+
} else if (results[0].status === false) {
|
|
1383
|
+
return Promise.reject((_a = results[0].error) === null || _a === void 0 ? void 0 : _a.message);
|
|
1384
|
+
} else {
|
|
1385
|
+
return results[0];
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
const Dialog = editor => {
|
|
1389
|
+
const helpers = {
|
|
1584
1390
|
imageSize: imageSize(editor),
|
|
1585
1391
|
addToBlobCache: addToBlobCache(editor),
|
|
1586
1392
|
createBlobCache: createBlobCache(editor),
|
|
@@ -1590,77 +1396,110 @@
|
|
|
1590
1396
|
serializeStyle: serializeStyle(editor),
|
|
1591
1397
|
uploadImage: uploadImage(editor)
|
|
1592
1398
|
};
|
|
1593
|
-
|
|
1594
|
-
collect(editor).then(
|
|
1399
|
+
const open = () => {
|
|
1400
|
+
collect(editor).then(info => {
|
|
1401
|
+
const state = createState(info);
|
|
1402
|
+
return {
|
|
1403
|
+
title: 'Insert/Edit Image',
|
|
1404
|
+
size: 'normal',
|
|
1405
|
+
body: makeDialogBody(info),
|
|
1406
|
+
buttons: [
|
|
1407
|
+
{
|
|
1408
|
+
type: 'cancel',
|
|
1409
|
+
name: 'cancel',
|
|
1410
|
+
text: 'Cancel'
|
|
1411
|
+
},
|
|
1412
|
+
{
|
|
1413
|
+
type: 'submit',
|
|
1414
|
+
name: 'save',
|
|
1415
|
+
text: 'Save',
|
|
1416
|
+
primary: true
|
|
1417
|
+
}
|
|
1418
|
+
],
|
|
1419
|
+
initialData: fromImageData(info.image),
|
|
1420
|
+
onSubmit: submitHandler(editor, info, helpers),
|
|
1421
|
+
onChange: changeHandler(helpers, info, state),
|
|
1422
|
+
onClose: closeHandler(state)
|
|
1423
|
+
};
|
|
1424
|
+
}).then(editor.windowManager.open);
|
|
1595
1425
|
};
|
|
1596
|
-
return { open
|
|
1426
|
+
return { open };
|
|
1597
1427
|
};
|
|
1598
1428
|
|
|
1599
|
-
|
|
1429
|
+
const register$1 = editor => {
|
|
1600
1430
|
editor.addCommand('mceImage', Dialog(editor).open);
|
|
1601
|
-
editor.addCommand('mceUpdateImage',
|
|
1602
|
-
editor.undoManager.transact(
|
|
1603
|
-
return insertOrUpdateImage(editor, data);
|
|
1604
|
-
});
|
|
1431
|
+
editor.addCommand('mceUpdateImage', (_ui, data) => {
|
|
1432
|
+
editor.undoManager.transact(() => insertOrUpdateImage(editor, data));
|
|
1605
1433
|
});
|
|
1606
1434
|
};
|
|
1607
1435
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
return className && /\bimage\b/.test(className);
|
|
1611
|
-
};
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
node.attr('contenteditable', state ? 'true' : null);
|
|
1617
|
-
};
|
|
1618
|
-
while (i--) {
|
|
1619
|
-
var node = nodes[i];
|
|
1620
|
-
if (hasImageClass(node)) {
|
|
1621
|
-
node.attr('contenteditable', state ? 'false' : null);
|
|
1622
|
-
global.each(node.getAll('figcaption'), toggleContentEditable);
|
|
1623
|
-
}
|
|
1624
|
-
}
|
|
1436
|
+
const hasImageClass = node => {
|
|
1437
|
+
const className = node.attr('class');
|
|
1438
|
+
return isNonNullable(className) && /\bimage\b/.test(className);
|
|
1439
|
+
};
|
|
1440
|
+
const toggleContentEditableState = state => nodes => {
|
|
1441
|
+
let i = nodes.length;
|
|
1442
|
+
const toggleContentEditable = node => {
|
|
1443
|
+
node.attr('contenteditable', state ? 'true' : null);
|
|
1625
1444
|
};
|
|
1445
|
+
while (i--) {
|
|
1446
|
+
const node = nodes[i];
|
|
1447
|
+
if (hasImageClass(node)) {
|
|
1448
|
+
node.attr('contenteditable', state ? 'false' : null);
|
|
1449
|
+
global.each(node.getAll('figcaption'), toggleContentEditable);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1626
1452
|
};
|
|
1627
|
-
|
|
1628
|
-
editor.on('PreInit',
|
|
1453
|
+
const setup = editor => {
|
|
1454
|
+
editor.on('PreInit', () => {
|
|
1629
1455
|
editor.parser.addNodeFilter('figure', toggleContentEditableState(true));
|
|
1630
1456
|
editor.serializer.addNodeFilter('figure', toggleContentEditableState(false));
|
|
1631
1457
|
});
|
|
1632
1458
|
};
|
|
1633
1459
|
|
|
1634
|
-
|
|
1460
|
+
const onSetupEditable = editor => api => {
|
|
1461
|
+
const nodeChanged = () => {
|
|
1462
|
+
api.setEnabled(editor.selection.isEditable());
|
|
1463
|
+
};
|
|
1464
|
+
editor.on('NodeChange', nodeChanged);
|
|
1465
|
+
nodeChanged();
|
|
1466
|
+
return () => {
|
|
1467
|
+
editor.off('NodeChange', nodeChanged);
|
|
1468
|
+
};
|
|
1469
|
+
};
|
|
1470
|
+
const register = editor => {
|
|
1635
1471
|
editor.ui.registry.addToggleButton('image', {
|
|
1636
1472
|
icon: 'image',
|
|
1637
1473
|
tooltip: 'Insert/edit image',
|
|
1638
1474
|
onAction: Dialog(editor).open,
|
|
1639
|
-
onSetup:
|
|
1475
|
+
onSetup: buttonApi => {
|
|
1640
1476
|
buttonApi.setActive(isNonNullable(getSelectedImage(editor)));
|
|
1641
|
-
|
|
1477
|
+
const unbindSelectorChanged = editor.selection.selectorChangedWithUnbind('img:not([data-mce-object]):not([data-mce-placeholder]),figure.image', buttonApi.setActive).unbind;
|
|
1478
|
+
const unbindEditable = onSetupEditable(editor)(buttonApi);
|
|
1479
|
+
return () => {
|
|
1480
|
+
unbindSelectorChanged();
|
|
1481
|
+
unbindEditable();
|
|
1482
|
+
};
|
|
1642
1483
|
}
|
|
1643
1484
|
});
|
|
1644
1485
|
editor.ui.registry.addMenuItem('image', {
|
|
1645
1486
|
icon: 'image',
|
|
1646
1487
|
text: 'Image...',
|
|
1647
|
-
onAction: Dialog(editor).open
|
|
1648
|
-
|
|
1649
|
-
editor.ui.registry.addContextMenu('image', {
|
|
1650
|
-
update: function (element) {
|
|
1651
|
-
return isFigure(element) || isImage(element) && !isPlaceholderImage(element) ? ['image'] : [];
|
|
1652
|
-
}
|
|
1488
|
+
onAction: Dialog(editor).open,
|
|
1489
|
+
onSetup: onSetupEditable(editor)
|
|
1653
1490
|
});
|
|
1491
|
+
editor.ui.registry.addContextMenu('image', { update: element => editor.selection.isEditable() && (isFigure(element) || isImage(element) && !isPlaceholderImage(element)) ? ['image'] : [] });
|
|
1654
1492
|
};
|
|
1655
1493
|
|
|
1656
|
-
|
|
1657
|
-
global$
|
|
1494
|
+
var Plugin = () => {
|
|
1495
|
+
global$4.add('image', editor => {
|
|
1496
|
+
register$2(editor);
|
|
1658
1497
|
setup(editor);
|
|
1659
1498
|
register(editor);
|
|
1660
1499
|
register$1(editor);
|
|
1661
1500
|
});
|
|
1662
|
-
}
|
|
1501
|
+
};
|
|
1663
1502
|
|
|
1664
1503
|
Plugin();
|
|
1665
1504
|
|
|
1666
|
-
}()
|
|
1505
|
+
})();
|