@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,188 +1,187 @@
|
|
|
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$
|
|
13
|
-
|
|
14
|
-
var global$6 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
8
|
+
var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
var
|
|
10
|
+
const hasProto = (v, constructor, predicate) => {
|
|
11
|
+
var _a;
|
|
12
|
+
if (predicate(v, constructor.prototype)) {
|
|
13
|
+
return true;
|
|
14
|
+
} else {
|
|
15
|
+
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const typeOf = x => {
|
|
19
|
+
const t = typeof x;
|
|
18
20
|
if (x === null) {
|
|
19
21
|
return 'null';
|
|
20
|
-
} else if (t === 'object' &&
|
|
22
|
+
} else if (t === 'object' && Array.isArray(x)) {
|
|
21
23
|
return 'array';
|
|
22
|
-
} else if (t === 'object' && (String
|
|
24
|
+
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
|
|
23
25
|
return 'string';
|
|
24
26
|
} else {
|
|
25
27
|
return t;
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
const isType = type => value => typeOf(value) === type;
|
|
31
|
+
const isSimpleType = type => value => typeof value === type;
|
|
32
|
+
const eq = t => a => t === a;
|
|
33
|
+
const isString = isType('string');
|
|
34
|
+
const isObject = isType('object');
|
|
35
|
+
const isArray = isType('array');
|
|
36
|
+
const isNull = eq(null);
|
|
37
|
+
const isBoolean = isSimpleType('boolean');
|
|
38
|
+
const isNullable = a => a === null || a === undefined;
|
|
39
|
+
const isNonNullable = a => !isNullable(a);
|
|
40
|
+
const isFunction = isSimpleType('function');
|
|
41
|
+
const isArrayOf = (value, pred) => {
|
|
42
|
+
if (isArray(value)) {
|
|
43
|
+
for (let i = 0, len = value.length; i < len; ++i) {
|
|
44
|
+
if (!pred(value[i])) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
42
51
|
};
|
|
43
|
-
var isString = isType('string');
|
|
44
|
-
var isArray = isType('array');
|
|
45
|
-
var isNull = eq(null);
|
|
46
|
-
var isBoolean = isSimpleType('boolean');
|
|
47
|
-
var isFunction = isSimpleType('function');
|
|
48
52
|
|
|
49
|
-
|
|
53
|
+
const noop = () => {
|
|
50
54
|
};
|
|
51
|
-
|
|
52
|
-
return
|
|
55
|
+
const constant = value => {
|
|
56
|
+
return () => {
|
|
53
57
|
return value;
|
|
54
58
|
};
|
|
55
59
|
};
|
|
56
|
-
|
|
57
|
-
return x;
|
|
58
|
-
};
|
|
59
|
-
var tripleEquals = function (a, b) {
|
|
60
|
+
const tripleEquals = (a, b) => {
|
|
60
61
|
return a === b;
|
|
61
62
|
};
|
|
62
|
-
var never = constant(false);
|
|
63
|
-
var always = constant(true);
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
getOrDie: function (msg) {
|
|
82
|
-
throw new Error(msg || 'error: getOrDie called on none.');
|
|
83
|
-
},
|
|
84
|
-
getOrNull: constant(null),
|
|
85
|
-
getOrUndefined: constant(undefined),
|
|
86
|
-
or: id,
|
|
87
|
-
orThunk: call,
|
|
88
|
-
map: none,
|
|
89
|
-
each: noop,
|
|
90
|
-
bind: none,
|
|
91
|
-
exists: never,
|
|
92
|
-
forall: always,
|
|
93
|
-
filter: function () {
|
|
94
|
-
return none();
|
|
95
|
-
},
|
|
96
|
-
toArray: function () {
|
|
97
|
-
return [];
|
|
98
|
-
},
|
|
99
|
-
toString: constant('none()')
|
|
100
|
-
};
|
|
101
|
-
return me;
|
|
102
|
-
}();
|
|
103
|
-
var some = function (a) {
|
|
104
|
-
var constant_a = constant(a);
|
|
105
|
-
var self = function () {
|
|
106
|
-
return me;
|
|
107
|
-
};
|
|
108
|
-
var bind = function (f) {
|
|
109
|
-
return f(a);
|
|
110
|
-
};
|
|
111
|
-
var me = {
|
|
112
|
-
fold: function (n, s) {
|
|
113
|
-
return s(a);
|
|
114
|
-
},
|
|
115
|
-
isSome: always,
|
|
116
|
-
isNone: never,
|
|
117
|
-
getOr: constant_a,
|
|
118
|
-
getOrThunk: constant_a,
|
|
119
|
-
getOrDie: constant_a,
|
|
120
|
-
getOrNull: constant_a,
|
|
121
|
-
getOrUndefined: constant_a,
|
|
122
|
-
or: self,
|
|
123
|
-
orThunk: self,
|
|
124
|
-
map: function (f) {
|
|
125
|
-
return some(f(a));
|
|
126
|
-
},
|
|
127
|
-
each: function (f) {
|
|
128
|
-
f(a);
|
|
129
|
-
},
|
|
130
|
-
bind: bind,
|
|
131
|
-
exists: bind,
|
|
132
|
-
forall: bind,
|
|
133
|
-
filter: function (f) {
|
|
134
|
-
return f(a) ? me : NONE;
|
|
135
|
-
},
|
|
136
|
-
toArray: function () {
|
|
137
|
-
return [a];
|
|
138
|
-
},
|
|
139
|
-
toString: function () {
|
|
140
|
-
return 'some(' + a + ')';
|
|
64
|
+
class Optional {
|
|
65
|
+
constructor(tag, value) {
|
|
66
|
+
this.tag = tag;
|
|
67
|
+
this.value = value;
|
|
68
|
+
}
|
|
69
|
+
static some(value) {
|
|
70
|
+
return new Optional(true, value);
|
|
71
|
+
}
|
|
72
|
+
static none() {
|
|
73
|
+
return Optional.singletonNone;
|
|
74
|
+
}
|
|
75
|
+
fold(onNone, onSome) {
|
|
76
|
+
if (this.tag) {
|
|
77
|
+
return onSome(this.value);
|
|
78
|
+
} else {
|
|
79
|
+
return onNone();
|
|
141
80
|
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
81
|
+
}
|
|
82
|
+
isSome() {
|
|
83
|
+
return this.tag;
|
|
84
|
+
}
|
|
85
|
+
isNone() {
|
|
86
|
+
return !this.tag;
|
|
87
|
+
}
|
|
88
|
+
map(mapper) {
|
|
89
|
+
if (this.tag) {
|
|
90
|
+
return Optional.some(mapper(this.value));
|
|
91
|
+
} else {
|
|
92
|
+
return Optional.none();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
bind(binder) {
|
|
96
|
+
if (this.tag) {
|
|
97
|
+
return binder(this.value);
|
|
98
|
+
} else {
|
|
99
|
+
return Optional.none();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exists(predicate) {
|
|
103
|
+
return this.tag && predicate(this.value);
|
|
104
|
+
}
|
|
105
|
+
forall(predicate) {
|
|
106
|
+
return !this.tag || predicate(this.value);
|
|
107
|
+
}
|
|
108
|
+
filter(predicate) {
|
|
109
|
+
if (!this.tag || predicate(this.value)) {
|
|
110
|
+
return this;
|
|
111
|
+
} else {
|
|
112
|
+
return Optional.none();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
getOr(replacement) {
|
|
116
|
+
return this.tag ? this.value : replacement;
|
|
117
|
+
}
|
|
118
|
+
or(replacement) {
|
|
119
|
+
return this.tag ? this : replacement;
|
|
120
|
+
}
|
|
121
|
+
getOrThunk(thunk) {
|
|
122
|
+
return this.tag ? this.value : thunk();
|
|
123
|
+
}
|
|
124
|
+
orThunk(thunk) {
|
|
125
|
+
return this.tag ? this : thunk();
|
|
126
|
+
}
|
|
127
|
+
getOrDie(message) {
|
|
128
|
+
if (!this.tag) {
|
|
129
|
+
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
|
|
130
|
+
} else {
|
|
131
|
+
return this.value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
static from(value) {
|
|
135
|
+
return isNonNullable(value) ? Optional.some(value) : Optional.none();
|
|
136
|
+
}
|
|
137
|
+
getOrNull() {
|
|
138
|
+
return this.tag ? this.value : null;
|
|
139
|
+
}
|
|
140
|
+
getOrUndefined() {
|
|
141
|
+
return this.value;
|
|
142
|
+
}
|
|
143
|
+
each(worker) {
|
|
144
|
+
if (this.tag) {
|
|
145
|
+
worker(this.value);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
toArray() {
|
|
149
|
+
return this.tag ? [this.value] : [];
|
|
150
|
+
}
|
|
151
|
+
toString() {
|
|
152
|
+
return this.tag ? `some(${ this.value })` : 'none()';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
Optional.singletonNone = new Optional(false);
|
|
153
156
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
var len = xs.length;
|
|
164
|
-
var r = new Array(len);
|
|
165
|
-
for (var i = 0; i < len; i++) {
|
|
166
|
-
var x = xs[i];
|
|
157
|
+
const nativeIndexOf = Array.prototype.indexOf;
|
|
158
|
+
const nativePush = Array.prototype.push;
|
|
159
|
+
const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
|
|
160
|
+
const contains = (xs, x) => rawIndexOf(xs, x) > -1;
|
|
161
|
+
const map = (xs, f) => {
|
|
162
|
+
const len = xs.length;
|
|
163
|
+
const r = new Array(len);
|
|
164
|
+
for (let i = 0; i < len; i++) {
|
|
165
|
+
const x = xs[i];
|
|
167
166
|
r[i] = f(x, i);
|
|
168
167
|
}
|
|
169
168
|
return r;
|
|
170
169
|
};
|
|
171
|
-
|
|
172
|
-
for (
|
|
173
|
-
|
|
170
|
+
const each$1 = (xs, f) => {
|
|
171
|
+
for (let i = 0, len = xs.length; i < len; i++) {
|
|
172
|
+
const x = xs[i];
|
|
174
173
|
f(x, i);
|
|
175
174
|
}
|
|
176
175
|
};
|
|
177
|
-
|
|
178
|
-
each$1(xs,
|
|
176
|
+
const foldl = (xs, f, acc) => {
|
|
177
|
+
each$1(xs, (x, i) => {
|
|
179
178
|
acc = f(acc, x, i);
|
|
180
179
|
});
|
|
181
180
|
return acc;
|
|
182
181
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
for (
|
|
182
|
+
const flatten = xs => {
|
|
183
|
+
const r = [];
|
|
184
|
+
for (let i = 0, len = xs.length; i < len; ++i) {
|
|
186
185
|
if (!isArray(xs[i])) {
|
|
187
186
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
188
187
|
}
|
|
@@ -190,12 +189,10 @@
|
|
|
190
189
|
}
|
|
191
190
|
return r;
|
|
192
191
|
};
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
for (var i = 0; i < arr.length; i++) {
|
|
198
|
-
var r = f(arr[i], i);
|
|
192
|
+
const bind = (xs, f) => flatten(map(xs, f));
|
|
193
|
+
const findMap = (arr, f) => {
|
|
194
|
+
for (let i = 0; i < arr.length; i++) {
|
|
195
|
+
const r = f(arr[i], i);
|
|
199
196
|
if (r.isSome()) {
|
|
200
197
|
return r;
|
|
201
198
|
}
|
|
@@ -203,74 +200,102 @@
|
|
|
203
200
|
return Optional.none();
|
|
204
201
|
};
|
|
205
202
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return lhs.exists(function (left) {
|
|
211
|
-
return comparator(left, rhs);
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
|
-
var cat = function (arr) {
|
|
215
|
-
var r = [];
|
|
216
|
-
var push = function (x) {
|
|
203
|
+
const is = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));
|
|
204
|
+
const cat = arr => {
|
|
205
|
+
const r = [];
|
|
206
|
+
const push = x => {
|
|
217
207
|
r.push(x);
|
|
218
208
|
};
|
|
219
|
-
for (
|
|
209
|
+
for (let i = 0; i < arr.length; i++) {
|
|
220
210
|
arr[i].each(push);
|
|
221
211
|
}
|
|
222
212
|
return r;
|
|
223
213
|
};
|
|
224
|
-
|
|
225
|
-
return b ? Optional.some(a) : Optional.none();
|
|
226
|
-
};
|
|
214
|
+
const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
|
|
227
215
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
216
|
+
const option = name => editor => editor.options.get(name);
|
|
217
|
+
const register$1 = editor => {
|
|
218
|
+
const registerOption = editor.options.register;
|
|
219
|
+
registerOption('link_assume_external_targets', {
|
|
220
|
+
processor: value => {
|
|
221
|
+
const valid = isString(value) || isBoolean(value);
|
|
222
|
+
if (valid) {
|
|
223
|
+
if (value === true) {
|
|
224
|
+
return {
|
|
225
|
+
value: 1,
|
|
226
|
+
valid
|
|
227
|
+
};
|
|
228
|
+
} else if (value === 'http' || value === 'https') {
|
|
229
|
+
return {
|
|
230
|
+
value,
|
|
231
|
+
valid
|
|
232
|
+
};
|
|
233
|
+
} else {
|
|
234
|
+
return {
|
|
235
|
+
value: 0,
|
|
236
|
+
valid
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
return {
|
|
241
|
+
valid: false,
|
|
242
|
+
message: 'Must be a string or a boolean.'
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
default: false
|
|
247
|
+
});
|
|
248
|
+
registerOption('link_context_toolbar', {
|
|
249
|
+
processor: 'boolean',
|
|
250
|
+
default: false
|
|
251
|
+
});
|
|
252
|
+
registerOption('link_list', { processor: value => isString(value) || isFunction(value) || isArrayOf(value, isObject) });
|
|
253
|
+
registerOption('link_default_target', { processor: 'string' });
|
|
254
|
+
registerOption('link_default_protocol', {
|
|
255
|
+
processor: 'string',
|
|
256
|
+
default: 'https'
|
|
257
|
+
});
|
|
258
|
+
registerOption('link_target_list', {
|
|
259
|
+
processor: value => isBoolean(value) || isArrayOf(value, isObject),
|
|
260
|
+
default: true
|
|
261
|
+
});
|
|
262
|
+
registerOption('link_rel_list', {
|
|
263
|
+
processor: 'object[]',
|
|
264
|
+
default: []
|
|
265
|
+
});
|
|
266
|
+
registerOption('link_class_list', {
|
|
267
|
+
processor: 'object[]',
|
|
268
|
+
default: []
|
|
269
|
+
});
|
|
270
|
+
registerOption('link_title', {
|
|
271
|
+
processor: 'boolean',
|
|
272
|
+
default: true
|
|
273
|
+
});
|
|
274
|
+
registerOption('allow_unsafe_link_target', {
|
|
275
|
+
processor: 'boolean',
|
|
276
|
+
default: false
|
|
277
|
+
});
|
|
278
|
+
registerOption('link_quicklink', {
|
|
279
|
+
processor: 'boolean',
|
|
280
|
+
default: false
|
|
281
|
+
});
|
|
266
282
|
};
|
|
283
|
+
const assumeExternalTargets = option('link_assume_external_targets');
|
|
284
|
+
const hasContextToolbar = option('link_context_toolbar');
|
|
285
|
+
const getLinkList = option('link_list');
|
|
286
|
+
const getDefaultLinkTarget = option('link_default_target');
|
|
287
|
+
const getDefaultLinkProtocol = option('link_default_protocol');
|
|
288
|
+
const getTargetList = option('link_target_list');
|
|
289
|
+
const getRelList = option('link_rel_list');
|
|
290
|
+
const getLinkClassList = option('link_class_list');
|
|
291
|
+
const shouldShowLinkTitle = option('link_title');
|
|
292
|
+
const allowUnsafeLinkTarget = option('allow_unsafe_link_target');
|
|
293
|
+
const useQuickLink = option('link_quicklink');
|
|
267
294
|
|
|
268
|
-
var global$
|
|
295
|
+
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
269
296
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
};
|
|
273
|
-
var getText = function (item) {
|
|
297
|
+
const getValue = item => isString(item.value) ? item.value : '';
|
|
298
|
+
const getText = item => {
|
|
274
299
|
if (isString(item.text)) {
|
|
275
300
|
return item.text;
|
|
276
301
|
} else if (isString(item.title)) {
|
|
@@ -279,121 +304,82 @@
|
|
|
279
304
|
return '';
|
|
280
305
|
}
|
|
281
306
|
};
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
global$
|
|
285
|
-
|
|
307
|
+
const sanitizeList = (list, extractValue) => {
|
|
308
|
+
const out = [];
|
|
309
|
+
global$4.each(list, item => {
|
|
310
|
+
const text = getText(item);
|
|
286
311
|
if (item.menu !== undefined) {
|
|
287
|
-
|
|
312
|
+
const items = sanitizeList(item.menu, extractValue);
|
|
288
313
|
out.push({
|
|
289
|
-
text
|
|
290
|
-
items
|
|
314
|
+
text,
|
|
315
|
+
items
|
|
291
316
|
});
|
|
292
317
|
} else {
|
|
293
|
-
|
|
318
|
+
const value = extractValue(item);
|
|
294
319
|
out.push({
|
|
295
|
-
text
|
|
296
|
-
value
|
|
320
|
+
text,
|
|
321
|
+
value
|
|
297
322
|
});
|
|
298
323
|
}
|
|
299
324
|
});
|
|
300
325
|
return out;
|
|
301
326
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
var createUi = function (name, label) {
|
|
316
|
-
return function (items) {
|
|
317
|
-
return {
|
|
318
|
-
name: name,
|
|
319
|
-
type: 'listbox',
|
|
320
|
-
label: label,
|
|
321
|
-
items: items
|
|
322
|
-
};
|
|
323
|
-
};
|
|
324
|
-
};
|
|
325
|
-
var ListOptions = {
|
|
326
|
-
sanitize: sanitize,
|
|
327
|
-
sanitizeWith: sanitizeWith,
|
|
328
|
-
createUi: createUi,
|
|
329
|
-
getValue: getValue
|
|
327
|
+
const sanitizeWith = (extracter = getValue) => list => Optional.from(list).map(list => sanitizeList(list, extracter));
|
|
328
|
+
const sanitize = list => sanitizeWith(getValue)(list);
|
|
329
|
+
const createUi = (name, label) => items => ({
|
|
330
|
+
name,
|
|
331
|
+
type: 'listbox',
|
|
332
|
+
label,
|
|
333
|
+
items
|
|
334
|
+
});
|
|
335
|
+
const ListOptions = {
|
|
336
|
+
sanitize,
|
|
337
|
+
sanitizeWith,
|
|
338
|
+
createUi,
|
|
339
|
+
getValue
|
|
330
340
|
};
|
|
331
341
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
340
|
-
return t;
|
|
341
|
-
};
|
|
342
|
-
return __assign.apply(this, arguments);
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
var keys = Object.keys;
|
|
346
|
-
var hasOwnProperty = Object.hasOwnProperty;
|
|
347
|
-
var each = function (obj, f) {
|
|
348
|
-
var props = keys(obj);
|
|
349
|
-
for (var k = 0, len = props.length; k < len; k++) {
|
|
350
|
-
var i = props[k];
|
|
351
|
-
var x = obj[i];
|
|
342
|
+
const keys = Object.keys;
|
|
343
|
+
const hasOwnProperty = Object.hasOwnProperty;
|
|
344
|
+
const each = (obj, f) => {
|
|
345
|
+
const props = keys(obj);
|
|
346
|
+
for (let k = 0, len = props.length; k < len; k++) {
|
|
347
|
+
const i = props[k];
|
|
348
|
+
const x = obj[i];
|
|
352
349
|
f(x, i);
|
|
353
350
|
}
|
|
354
351
|
};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
r[i] = x;
|
|
358
|
-
};
|
|
352
|
+
const objAcc = r => (x, i) => {
|
|
353
|
+
r[i] = x;
|
|
359
354
|
};
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
each(obj, function (x, i) {
|
|
355
|
+
const internalFilter = (obj, pred, onTrue, onFalse) => {
|
|
356
|
+
each(obj, (x, i) => {
|
|
363
357
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
364
358
|
});
|
|
365
|
-
return r;
|
|
366
359
|
};
|
|
367
|
-
|
|
368
|
-
|
|
360
|
+
const filter = (obj, pred) => {
|
|
361
|
+
const t = {};
|
|
369
362
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
370
363
|
return t;
|
|
371
364
|
};
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
};
|
|
375
|
-
var hasNonNullableKey = function (obj, key) {
|
|
376
|
-
return has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
377
|
-
};
|
|
365
|
+
const has = (obj, key) => hasOwnProperty.call(obj, key);
|
|
366
|
+
const hasNonNullableKey = (obj, key) => has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
378
367
|
|
|
379
|
-
var global$
|
|
368
|
+
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
|
380
369
|
|
|
381
|
-
var global$
|
|
370
|
+
var global$2 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
382
371
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
var isLink = function (elm) {
|
|
387
|
-
return isAnchor(elm) && !!getHref(elm);
|
|
388
|
-
};
|
|
389
|
-
var collectNodesInRange = function (rng, predicate) {
|
|
372
|
+
const isAnchor = elm => isNonNullable(elm) && elm.nodeName.toLowerCase() === 'a';
|
|
373
|
+
const isLink = elm => isAnchor(elm) && !!getHref(elm);
|
|
374
|
+
const collectNodesInRange = (rng, predicate) => {
|
|
390
375
|
if (rng.collapsed) {
|
|
391
376
|
return [];
|
|
392
377
|
} else {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
378
|
+
const contents = rng.cloneContents();
|
|
379
|
+
const firstChild = contents.firstChild;
|
|
380
|
+
const walker = new global$3(firstChild, contents);
|
|
381
|
+
const elements = [];
|
|
382
|
+
let current = firstChild;
|
|
397
383
|
do {
|
|
398
384
|
if (predicate(current)) {
|
|
399
385
|
elements.push(current);
|
|
@@ -402,87 +388,81 @@
|
|
|
402
388
|
return elements;
|
|
403
389
|
}
|
|
404
390
|
};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
var href = elm.getAttribute('data-mce-href');
|
|
410
|
-
return href ? href : elm.getAttribute('href');
|
|
391
|
+
const hasProtocol = url => /^\w+:/i.test(url);
|
|
392
|
+
const getHref = elm => {
|
|
393
|
+
var _a, _b;
|
|
394
|
+
return (_b = (_a = elm.getAttribute('data-mce-href')) !== null && _a !== void 0 ? _a : elm.getAttribute('href')) !== null && _b !== void 0 ? _b : '';
|
|
411
395
|
};
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
};
|
|
418
|
-
var addTargetRules = function (rels) {
|
|
396
|
+
const applyRelTargetRules = (rel, isUnsafe) => {
|
|
397
|
+
const rules = ['noopener'];
|
|
398
|
+
const rels = rel ? rel.split(/\s+/) : [];
|
|
399
|
+
const toString = rels => global$4.trim(rels.sort().join(' '));
|
|
400
|
+
const addTargetRules = rels => {
|
|
419
401
|
rels = removeTargetRules(rels);
|
|
420
402
|
return rels.length > 0 ? rels.concat(rules) : rules;
|
|
421
403
|
};
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return global$5.inArray(rules, val) === -1;
|
|
425
|
-
});
|
|
426
|
-
};
|
|
427
|
-
var newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
|
|
404
|
+
const removeTargetRules = rels => rels.filter(val => global$4.inArray(rules, val) === -1);
|
|
405
|
+
const newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
|
|
428
406
|
return newRels.length > 0 ? toString(newRels) : '';
|
|
429
407
|
};
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var getAnchorElement = function (editor, selectedElm) {
|
|
434
|
-
selectedElm = selectedElm || editor.selection.getNode();
|
|
408
|
+
const trimCaretContainers = text => text.replace(/\uFEFF/g, '');
|
|
409
|
+
const getAnchorElement = (editor, selectedElm) => {
|
|
410
|
+
selectedElm = selectedElm || getLinksInSelection(editor.selection.getRng())[0] || editor.selection.getNode();
|
|
435
411
|
if (isImageFigure(selectedElm)) {
|
|
436
|
-
return editor.dom.select('a[href]', selectedElm)[0];
|
|
412
|
+
return Optional.from(editor.dom.select('a[href]', selectedElm)[0]);
|
|
437
413
|
} else {
|
|
438
|
-
return editor.dom.getParent(selectedElm, 'a[href]');
|
|
414
|
+
return Optional.from(editor.dom.getParent(selectedElm, 'a[href]'));
|
|
439
415
|
}
|
|
440
416
|
};
|
|
441
|
-
|
|
442
|
-
|
|
417
|
+
const isInAnchor = (editor, selectedElm) => getAnchorElement(editor, selectedElm).isSome();
|
|
418
|
+
const getAnchorText = (selection, anchorElm) => {
|
|
419
|
+
const text = anchorElm.fold(() => selection.getContent({ format: 'text' }), anchorElm => anchorElm.innerText || anchorElm.textContent || '');
|
|
443
420
|
return trimCaretContainers(text);
|
|
444
421
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
return
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
422
|
+
const getLinksInSelection = rng => collectNodesInRange(rng, isLink);
|
|
423
|
+
const getLinks$1 = elements => global$4.grep(elements, isLink);
|
|
424
|
+
const hasLinks = elements => getLinks$1(elements).length > 0;
|
|
425
|
+
const hasLinksInSelection = rng => getLinksInSelection(rng).length > 0;
|
|
426
|
+
const isOnlyTextSelected = editor => {
|
|
427
|
+
const inlineTextElements = editor.schema.getTextInlineElements();
|
|
428
|
+
const isElement = elm => elm.nodeType === 1 && !isAnchor(elm) && !has(inlineTextElements, elm.nodeName.toLowerCase());
|
|
429
|
+
const isInBlockAnchor = getAnchorElement(editor).exists(anchor => anchor.hasAttribute('data-mce-block'));
|
|
430
|
+
if (isInBlockAnchor) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
const rng = editor.selection.getRng();
|
|
434
|
+
if (!rng.collapsed) {
|
|
435
|
+
const elements = collectNodesInRange(rng, isElement);
|
|
436
|
+
return elements.length === 0;
|
|
437
|
+
} else {
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
461
440
|
};
|
|
462
|
-
|
|
463
|
-
|
|
441
|
+
const isImageFigure = elm => isNonNullable(elm) && elm.nodeName === 'FIGURE' && /\bimage\b/i.test(elm.className);
|
|
442
|
+
const getLinkAttrs = data => {
|
|
443
|
+
const attrs = [
|
|
464
444
|
'title',
|
|
465
445
|
'rel',
|
|
466
446
|
'class',
|
|
467
447
|
'target'
|
|
468
448
|
];
|
|
469
|
-
return foldl(attrs,
|
|
470
|
-
data[key].each(
|
|
449
|
+
return foldl(attrs, (acc, key) => {
|
|
450
|
+
data[key].each(value => {
|
|
471
451
|
acc[key] = value.length > 0 ? value : null;
|
|
472
452
|
});
|
|
473
453
|
return acc;
|
|
474
454
|
}, { href: data.href });
|
|
475
455
|
};
|
|
476
|
-
|
|
456
|
+
const handleExternalTargets = (href, assumeExternalTargets) => {
|
|
477
457
|
if ((assumeExternalTargets === 'http' || assumeExternalTargets === 'https') && !hasProtocol(href)) {
|
|
478
458
|
return assumeExternalTargets + '://' + href;
|
|
479
459
|
}
|
|
480
460
|
return href;
|
|
481
461
|
};
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (
|
|
485
|
-
|
|
462
|
+
const applyLinkOverrides = (editor, linkAttrs) => {
|
|
463
|
+
const newLinkAttrs = { ...linkAttrs };
|
|
464
|
+
if (getRelList(editor).length === 0 && !allowUnsafeLinkTarget(editor)) {
|
|
465
|
+
const newRel = applyRelTargetRules(newLinkAttrs.rel, newLinkAttrs.target === '_blank');
|
|
486
466
|
newLinkAttrs.rel = newRel ? newRel : null;
|
|
487
467
|
}
|
|
488
468
|
if (Optional.from(newLinkAttrs.target).isNone() && getTargetList(editor) === false) {
|
|
@@ -491,8 +471,8 @@
|
|
|
491
471
|
newLinkAttrs.href = handleExternalTargets(newLinkAttrs.href, assumeExternalTargets(editor));
|
|
492
472
|
return newLinkAttrs;
|
|
493
473
|
};
|
|
494
|
-
|
|
495
|
-
text.each(
|
|
474
|
+
const updateLink = (editor, anchorElm, text, linkAttrs) => {
|
|
475
|
+
text.each(text => {
|
|
496
476
|
if (has(anchorElm, 'innerText')) {
|
|
497
477
|
anchorElm.innerText = text;
|
|
498
478
|
} else {
|
|
@@ -502,39 +482,40 @@
|
|
|
502
482
|
editor.dom.setAttribs(anchorElm, linkAttrs);
|
|
503
483
|
editor.selection.select(anchorElm);
|
|
504
484
|
};
|
|
505
|
-
|
|
485
|
+
const createLink = (editor, selectedElm, text, linkAttrs) => {
|
|
486
|
+
const dom = editor.dom;
|
|
506
487
|
if (isImageFigure(selectedElm)) {
|
|
507
|
-
linkImageFigure(
|
|
488
|
+
linkImageFigure(dom, selectedElm, linkAttrs);
|
|
508
489
|
} else {
|
|
509
|
-
text.fold(
|
|
490
|
+
text.fold(() => {
|
|
510
491
|
editor.execCommand('mceInsertLink', false, linkAttrs);
|
|
511
|
-
},
|
|
512
|
-
editor.insertContent(
|
|
492
|
+
}, text => {
|
|
493
|
+
editor.insertContent(dom.createHTML('a', linkAttrs, dom.encode(text)));
|
|
513
494
|
});
|
|
514
495
|
}
|
|
515
496
|
};
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
editor.undoManager.transact(
|
|
497
|
+
const linkDomMutation = (editor, attachState, data) => {
|
|
498
|
+
const selectedElm = editor.selection.getNode();
|
|
499
|
+
const anchorElm = getAnchorElement(editor, selectedElm);
|
|
500
|
+
const linkAttrs = applyLinkOverrides(editor, getLinkAttrs(data));
|
|
501
|
+
editor.undoManager.transact(() => {
|
|
521
502
|
if (data.href === attachState.href) {
|
|
522
503
|
attachState.attach();
|
|
523
504
|
}
|
|
524
|
-
|
|
525
|
-
editor.focus();
|
|
526
|
-
updateLink(editor, anchorElm, data.text, linkAttrs);
|
|
527
|
-
} else {
|
|
505
|
+
anchorElm.fold(() => {
|
|
528
506
|
createLink(editor, selectedElm, data.text, linkAttrs);
|
|
529
|
-
}
|
|
507
|
+
}, elm => {
|
|
508
|
+
editor.focus();
|
|
509
|
+
updateLink(editor, elm, data.text, linkAttrs);
|
|
510
|
+
});
|
|
530
511
|
});
|
|
531
512
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
513
|
+
const unlinkSelection = editor => {
|
|
514
|
+
const dom = editor.dom, selection = editor.selection;
|
|
515
|
+
const bookmark = selection.getBookmark();
|
|
516
|
+
const rng = selection.getRng().cloneRange();
|
|
517
|
+
const startAnchorElm = dom.getParent(rng.startContainer, 'a[href]', editor.getBody());
|
|
518
|
+
const endAnchorElm = dom.getParent(rng.endContainer, 'a[href]', editor.getBody());
|
|
538
519
|
if (startAnchorElm) {
|
|
539
520
|
rng.setStartBefore(startAnchorElm);
|
|
540
521
|
}
|
|
@@ -545,9 +526,9 @@
|
|
|
545
526
|
editor.execCommand('unlink');
|
|
546
527
|
selection.moveToBookmark(bookmark);
|
|
547
528
|
};
|
|
548
|
-
|
|
549
|
-
editor.undoManager.transact(
|
|
550
|
-
|
|
529
|
+
const unlinkDomMutation = editor => {
|
|
530
|
+
editor.undoManager.transact(() => {
|
|
531
|
+
const node = editor.selection.getNode();
|
|
551
532
|
if (isImageFigure(node)) {
|
|
552
533
|
unlinkImageFigure(editor, node);
|
|
553
534
|
} else {
|
|
@@ -556,78 +537,88 @@
|
|
|
556
537
|
editor.focus();
|
|
557
538
|
});
|
|
558
539
|
};
|
|
559
|
-
|
|
560
|
-
|
|
540
|
+
const unwrapOptions = data => {
|
|
541
|
+
const {
|
|
542
|
+
class: cls,
|
|
543
|
+
href,
|
|
544
|
+
rel,
|
|
545
|
+
target,
|
|
546
|
+
text,
|
|
547
|
+
title
|
|
548
|
+
} = data;
|
|
561
549
|
return filter({
|
|
562
550
|
class: cls.getOrNull(),
|
|
563
|
-
href
|
|
551
|
+
href,
|
|
564
552
|
rel: rel.getOrNull(),
|
|
565
553
|
target: target.getOrNull(),
|
|
566
554
|
text: text.getOrNull(),
|
|
567
555
|
title: title.getOrNull()
|
|
568
|
-
},
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
556
|
+
}, (v, _k) => isNull(v) === false);
|
|
557
|
+
};
|
|
558
|
+
const sanitizeData = (editor, data) => {
|
|
559
|
+
const getOption = editor.options.get;
|
|
560
|
+
const uriOptions = {
|
|
561
|
+
allow_html_data_urls: getOption('allow_html_data_urls'),
|
|
562
|
+
allow_script_urls: getOption('allow_script_urls'),
|
|
563
|
+
allow_svg_data_urls: getOption('allow_svg_data_urls')
|
|
564
|
+
};
|
|
565
|
+
const href = data.href;
|
|
566
|
+
return {
|
|
567
|
+
...data,
|
|
568
|
+
href: global$2.isDomSafe(href, 'a', uriOptions) ? href : ''
|
|
569
|
+
};
|
|
575
570
|
};
|
|
576
|
-
|
|
577
|
-
|
|
571
|
+
const link = (editor, attachState, data) => {
|
|
572
|
+
const sanitizedData = sanitizeData(editor, data);
|
|
578
573
|
editor.hasPlugin('rtc', true) ? editor.execCommand('createlink', false, unwrapOptions(sanitizedData)) : linkDomMutation(editor, attachState, sanitizedData);
|
|
579
574
|
};
|
|
580
|
-
|
|
575
|
+
const unlink = editor => {
|
|
581
576
|
editor.hasPlugin('rtc', true) ? editor.execCommand('unlink') : unlinkDomMutation(editor);
|
|
582
577
|
};
|
|
583
|
-
|
|
584
|
-
var
|
|
578
|
+
const unlinkImageFigure = (editor, fig) => {
|
|
579
|
+
var _a;
|
|
580
|
+
const img = editor.dom.select('img', fig)[0];
|
|
585
581
|
if (img) {
|
|
586
|
-
|
|
582
|
+
const a = editor.dom.getParents(img, 'a[href]', fig)[0];
|
|
587
583
|
if (a) {
|
|
588
|
-
a.parentNode.insertBefore(img, a);
|
|
584
|
+
(_a = a.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(img, a);
|
|
589
585
|
editor.dom.remove(a);
|
|
590
586
|
}
|
|
591
587
|
}
|
|
592
588
|
};
|
|
593
|
-
|
|
594
|
-
var
|
|
589
|
+
const linkImageFigure = (dom, fig, attrs) => {
|
|
590
|
+
var _a;
|
|
591
|
+
const img = dom.select('img', fig)[0];
|
|
595
592
|
if (img) {
|
|
596
|
-
|
|
597
|
-
img.parentNode.insertBefore(a, img);
|
|
593
|
+
const a = dom.create('a', attrs);
|
|
594
|
+
(_a = img.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(a, img);
|
|
598
595
|
a.appendChild(img);
|
|
599
596
|
}
|
|
600
597
|
};
|
|
601
598
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
attach: noop
|
|
624
|
-
}
|
|
625
|
-
},
|
|
626
|
-
text: hasPersistentText ? persistentText : i.text
|
|
627
|
-
};
|
|
628
|
-
}) : Optional.none();
|
|
599
|
+
const isListGroup = item => hasNonNullableKey(item, 'items');
|
|
600
|
+
const findTextByValue = (value, catalog) => findMap(catalog, item => {
|
|
601
|
+
if (isListGroup(item)) {
|
|
602
|
+
return findTextByValue(value, item.items);
|
|
603
|
+
} else {
|
|
604
|
+
return someIf(item.value === value, item);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
const getDelta = (persistentText, fieldName, catalog, data) => {
|
|
608
|
+
const value = data[fieldName];
|
|
609
|
+
const hasPersistentText = persistentText.length > 0;
|
|
610
|
+
return value !== undefined ? findTextByValue(value, catalog).map(i => ({
|
|
611
|
+
url: {
|
|
612
|
+
value: i.value,
|
|
613
|
+
meta: {
|
|
614
|
+
text: hasPersistentText ? persistentText : i.text,
|
|
615
|
+
attach: noop
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
text: hasPersistentText ? persistentText : i.text
|
|
619
|
+
})) : Optional.none();
|
|
629
620
|
};
|
|
630
|
-
|
|
621
|
+
const findCatalog = (catalogs, fieldName) => {
|
|
631
622
|
if (fieldName === 'link') {
|
|
632
623
|
return catalogs.link;
|
|
633
624
|
} else if (fieldName === 'anchor') {
|
|
@@ -636,43 +627,44 @@
|
|
|
636
627
|
return Optional.none();
|
|
637
628
|
}
|
|
638
629
|
};
|
|
639
|
-
|
|
640
|
-
|
|
630
|
+
const init = (initialData, linkCatalog) => {
|
|
631
|
+
const persistentData = {
|
|
641
632
|
text: initialData.text,
|
|
642
633
|
title: initialData.title
|
|
643
634
|
};
|
|
644
|
-
|
|
645
|
-
|
|
635
|
+
const getTitleFromUrlChange = url => {
|
|
636
|
+
var _a;
|
|
637
|
+
return someIf(persistentData.title.length <= 0, Optional.from((_a = url.meta) === null || _a === void 0 ? void 0 : _a.title).getOr(''));
|
|
646
638
|
};
|
|
647
|
-
|
|
648
|
-
|
|
639
|
+
const getTextFromUrlChange = url => {
|
|
640
|
+
var _a;
|
|
641
|
+
return someIf(persistentData.text.length <= 0, Optional.from((_a = url.meta) === null || _a === void 0 ? void 0 : _a.text).getOr(url.value));
|
|
649
642
|
};
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
643
|
+
const onUrlChange = data => {
|
|
644
|
+
const text = getTextFromUrlChange(data.url);
|
|
645
|
+
const title = getTitleFromUrlChange(data.url);
|
|
653
646
|
if (text.isSome() || title.isSome()) {
|
|
654
|
-
return Optional.some(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}).getOr({})));
|
|
647
|
+
return Optional.some({
|
|
648
|
+
...text.map(text => ({ text })).getOr({}),
|
|
649
|
+
...title.map(title => ({ title })).getOr({})
|
|
650
|
+
});
|
|
659
651
|
} else {
|
|
660
652
|
return Optional.none();
|
|
661
653
|
}
|
|
662
654
|
};
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return getDelta(persistentData.text, change
|
|
655
|
+
const onCatalogChange = (data, change) => {
|
|
656
|
+
const catalog = findCatalog(linkCatalog, change).getOr([]);
|
|
657
|
+
return getDelta(persistentData.text, change, catalog, data);
|
|
666
658
|
};
|
|
667
|
-
|
|
668
|
-
|
|
659
|
+
const onChange = (getData, change) => {
|
|
660
|
+
const name = change.name;
|
|
669
661
|
if (name === 'url') {
|
|
670
662
|
return onUrlChange(getData());
|
|
671
663
|
} else if (contains([
|
|
672
664
|
'anchor',
|
|
673
665
|
'link'
|
|
674
666
|
], name)) {
|
|
675
|
-
return onCatalogChange(getData(),
|
|
667
|
+
return onCatalogChange(getData(), name);
|
|
676
668
|
} else if (name === 'text' || name === 'title') {
|
|
677
669
|
persistentData[name] = getData()[name];
|
|
678
670
|
return Optional.none();
|
|
@@ -680,70 +672,60 @@
|
|
|
680
672
|
return Optional.none();
|
|
681
673
|
}
|
|
682
674
|
};
|
|
683
|
-
return { onChange
|
|
675
|
+
return { onChange };
|
|
684
676
|
};
|
|
685
|
-
|
|
686
|
-
init
|
|
687
|
-
getDelta
|
|
677
|
+
const DialogChanges = {
|
|
678
|
+
init,
|
|
679
|
+
getDelta
|
|
688
680
|
};
|
|
689
681
|
|
|
690
|
-
var global$
|
|
691
|
-
|
|
692
|
-
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
682
|
+
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
693
683
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
global$
|
|
697
|
-
editor.windowManager.confirm(message,
|
|
684
|
+
const delayedConfirm = (editor, message, callback) => {
|
|
685
|
+
const rng = editor.selection.getRng();
|
|
686
|
+
global$1.setEditorTimeout(editor, () => {
|
|
687
|
+
editor.windowManager.confirm(message, state => {
|
|
698
688
|
editor.selection.setRng(rng);
|
|
699
689
|
callback(state);
|
|
700
690
|
});
|
|
701
691
|
});
|
|
702
692
|
};
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
693
|
+
const tryEmailTransform = data => {
|
|
694
|
+
const url = data.href;
|
|
695
|
+
const suggestMailTo = url.indexOf('@') > 0 && url.indexOf('/') === -1 && url.indexOf('mailto:') === -1;
|
|
706
696
|
return suggestMailTo ? Optional.some({
|
|
707
697
|
message: 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?',
|
|
708
|
-
preprocess:
|
|
709
|
-
|
|
710
|
-
|
|
698
|
+
preprocess: oldData => ({
|
|
699
|
+
...oldData,
|
|
700
|
+
href: 'mailto:' + url
|
|
701
|
+
})
|
|
711
702
|
}) : Optional.none();
|
|
712
703
|
};
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
};
|
|
704
|
+
const tryProtocolTransform = (assumeExternalTargets, defaultLinkProtocol) => data => {
|
|
705
|
+
const url = data.href;
|
|
706
|
+
const suggestProtocol = assumeExternalTargets === 1 && !hasProtocol(url) || assumeExternalTargets === 0 && /^\s*www(\.|\d\.)/i.test(url);
|
|
707
|
+
return suggestProtocol ? Optional.some({
|
|
708
|
+
message: `The URL you entered seems to be an external link. Do you want to add the required ${ defaultLinkProtocol }:// prefix?`,
|
|
709
|
+
preprocess: oldData => ({
|
|
710
|
+
...oldData,
|
|
711
|
+
href: defaultLinkProtocol + '://' + url
|
|
712
|
+
})
|
|
713
|
+
}) : Optional.none();
|
|
724
714
|
};
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
}).fold(function () {
|
|
732
|
-
return global$1.resolve(data);
|
|
733
|
-
}, function (transform) {
|
|
734
|
-
return new global$1(function (callback) {
|
|
735
|
-
delayedConfirm(editor, transform.message, function (state) {
|
|
736
|
-
callback(state ? transform.preprocess(data) : data);
|
|
737
|
-
});
|
|
738
|
-
});
|
|
715
|
+
const preprocess = (editor, data) => findMap([
|
|
716
|
+
tryEmailTransform,
|
|
717
|
+
tryProtocolTransform(assumeExternalTargets(editor), getDefaultLinkProtocol(editor))
|
|
718
|
+
], f => f(data)).fold(() => Promise.resolve(data), transform => new Promise(callback => {
|
|
719
|
+
delayedConfirm(editor, transform.message, state => {
|
|
720
|
+
callback(state ? transform.preprocess(data) : data);
|
|
739
721
|
});
|
|
740
|
-
};
|
|
741
|
-
|
|
722
|
+
}));
|
|
723
|
+
const DialogConfirms = { preprocess };
|
|
742
724
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
725
|
+
const getAnchors = editor => {
|
|
726
|
+
const anchorNodes = editor.dom.select('a:not([href])');
|
|
727
|
+
const anchors = bind(anchorNodes, anchor => {
|
|
728
|
+
const id = anchor.name || anchor.id;
|
|
747
729
|
return id ? [{
|
|
748
730
|
text: id,
|
|
749
731
|
value: '#' + id
|
|
@@ -754,81 +736,63 @@
|
|
|
754
736
|
value: ''
|
|
755
737
|
}].concat(anchors)) : Optional.none();
|
|
756
738
|
};
|
|
757
|
-
|
|
739
|
+
const AnchorListOptions = { getAnchors };
|
|
758
740
|
|
|
759
|
-
|
|
760
|
-
|
|
741
|
+
const getClasses = editor => {
|
|
742
|
+
const list = getLinkClassList(editor);
|
|
761
743
|
if (list.length > 0) {
|
|
762
744
|
return ListOptions.sanitize(list);
|
|
763
745
|
}
|
|
764
746
|
return Optional.none();
|
|
765
747
|
};
|
|
766
|
-
|
|
748
|
+
const ClassListOptions = { getClasses };
|
|
767
749
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
var parseJson = function (text) {
|
|
750
|
+
const parseJson = text => {
|
|
771
751
|
try {
|
|
772
752
|
return Optional.some(JSON.parse(text));
|
|
773
753
|
} catch (err) {
|
|
774
754
|
return Optional.none();
|
|
775
755
|
}
|
|
776
756
|
};
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
var linkList = getLinkList(editor);
|
|
782
|
-
return new global$1(function (callback) {
|
|
757
|
+
const getLinks = editor => {
|
|
758
|
+
const extractor = item => editor.convertURL(item.value || item.url || '', 'href');
|
|
759
|
+
const linkList = getLinkList(editor);
|
|
760
|
+
return new Promise(resolve => {
|
|
783
761
|
if (isString(linkList)) {
|
|
784
|
-
|
|
785
|
-
url: linkList,
|
|
786
|
-
success: function (text) {
|
|
787
|
-
return callback(parseJson(text));
|
|
788
|
-
},
|
|
789
|
-
error: function (_) {
|
|
790
|
-
return callback(Optional.none());
|
|
791
|
-
}
|
|
792
|
-
});
|
|
762
|
+
fetch(linkList).then(res => res.ok ? res.text().then(parseJson) : Promise.reject()).then(resolve, () => resolve(Optional.none()));
|
|
793
763
|
} else if (isFunction(linkList)) {
|
|
794
|
-
linkList(
|
|
795
|
-
return callback(Optional.some(output));
|
|
796
|
-
});
|
|
764
|
+
linkList(output => resolve(Optional.some(output)));
|
|
797
765
|
} else {
|
|
798
|
-
|
|
766
|
+
resolve(Optional.from(linkList));
|
|
799
767
|
}
|
|
800
|
-
}).then(
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
});
|
|
812
|
-
});
|
|
768
|
+
}).then(optItems => optItems.bind(ListOptions.sanitizeWith(extractor)).map(items => {
|
|
769
|
+
if (items.length > 0) {
|
|
770
|
+
const noneItem = [{
|
|
771
|
+
text: 'None',
|
|
772
|
+
value: ''
|
|
773
|
+
}];
|
|
774
|
+
return noneItem.concat(items);
|
|
775
|
+
} else {
|
|
776
|
+
return items;
|
|
777
|
+
}
|
|
778
|
+
}));
|
|
813
779
|
};
|
|
814
|
-
|
|
780
|
+
const LinkListOptions = { getLinks };
|
|
815
781
|
|
|
816
|
-
|
|
817
|
-
|
|
782
|
+
const getRels = (editor, initialTarget) => {
|
|
783
|
+
const list = getRelList(editor);
|
|
818
784
|
if (list.length > 0) {
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
};
|
|
824
|
-
var sanitizer = enforceSafe ? ListOptions.sanitizeWith(safeRelExtractor) : ListOptions.sanitize;
|
|
785
|
+
const isTargetBlank = is(initialTarget, '_blank');
|
|
786
|
+
const enforceSafe = allowUnsafeLinkTarget(editor) === false;
|
|
787
|
+
const safeRelExtractor = item => applyRelTargetRules(ListOptions.getValue(item), isTargetBlank);
|
|
788
|
+
const sanitizer = enforceSafe ? ListOptions.sanitizeWith(safeRelExtractor) : ListOptions.sanitize;
|
|
825
789
|
return sanitizer(list);
|
|
826
790
|
}
|
|
827
791
|
return Optional.none();
|
|
828
792
|
};
|
|
829
|
-
|
|
793
|
+
const RelOptions = { getRels };
|
|
830
794
|
|
|
831
|
-
|
|
795
|
+
const fallbacks = [
|
|
832
796
|
{
|
|
833
797
|
text: 'Current window',
|
|
834
798
|
value: ''
|
|
@@ -838,98 +802,88 @@
|
|
|
838
802
|
value: '_blank'
|
|
839
803
|
}
|
|
840
804
|
];
|
|
841
|
-
|
|
842
|
-
|
|
805
|
+
const getTargets = editor => {
|
|
806
|
+
const list = getTargetList(editor);
|
|
843
807
|
if (isArray(list)) {
|
|
844
|
-
return ListOptions.sanitize(list).orThunk(
|
|
845
|
-
return Optional.some(fallbacks);
|
|
846
|
-
});
|
|
808
|
+
return ListOptions.sanitize(list).orThunk(() => Optional.some(fallbacks));
|
|
847
809
|
} else if (list === false) {
|
|
848
810
|
return Optional.none();
|
|
849
811
|
}
|
|
850
812
|
return Optional.some(fallbacks);
|
|
851
813
|
};
|
|
852
|
-
|
|
814
|
+
const TargetOptions = { getTargets };
|
|
853
815
|
|
|
854
|
-
|
|
855
|
-
|
|
816
|
+
const nonEmptyAttr = (dom, elem, name) => {
|
|
817
|
+
const val = dom.getAttrib(elem, name);
|
|
856
818
|
return val !== null && val.length > 0 ? Optional.some(val) : Optional.none();
|
|
857
819
|
};
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
820
|
+
const extractFromAnchor = (editor, anchor) => {
|
|
821
|
+
const dom = editor.dom;
|
|
822
|
+
const onlyText = isOnlyTextSelected(editor);
|
|
823
|
+
const text = onlyText ? Optional.some(getAnchorText(editor.selection, anchor)) : Optional.none();
|
|
824
|
+
const url = anchor.bind(anchorElm => Optional.from(dom.getAttrib(anchorElm, 'href')));
|
|
825
|
+
const target = anchor.bind(anchorElm => Optional.from(dom.getAttrib(anchorElm, 'target')));
|
|
826
|
+
const rel = anchor.bind(anchorElm => nonEmptyAttr(dom, anchorElm, 'rel'));
|
|
827
|
+
const linkClass = anchor.bind(anchorElm => nonEmptyAttr(dom, anchorElm, 'class'));
|
|
828
|
+
const title = anchor.bind(anchorElm => nonEmptyAttr(dom, anchorElm, 'title'));
|
|
867
829
|
return {
|
|
868
|
-
url
|
|
869
|
-
text
|
|
870
|
-
title
|
|
871
|
-
target
|
|
872
|
-
rel
|
|
873
|
-
linkClass
|
|
830
|
+
url,
|
|
831
|
+
text,
|
|
832
|
+
title,
|
|
833
|
+
target,
|
|
834
|
+
rel,
|
|
835
|
+
linkClass
|
|
874
836
|
};
|
|
875
837
|
};
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
};
|
|
893
|
-
var DialogInfo = { collect: collect };
|
|
838
|
+
const collect = (editor, linkNode) => LinkListOptions.getLinks(editor).then(links => {
|
|
839
|
+
const anchor = extractFromAnchor(editor, linkNode);
|
|
840
|
+
return {
|
|
841
|
+
anchor,
|
|
842
|
+
catalogs: {
|
|
843
|
+
targets: TargetOptions.getTargets(editor),
|
|
844
|
+
rels: RelOptions.getRels(editor, anchor.target),
|
|
845
|
+
classes: ClassListOptions.getClasses(editor),
|
|
846
|
+
anchor: AnchorListOptions.getAnchors(editor),
|
|
847
|
+
link: links
|
|
848
|
+
},
|
|
849
|
+
optNode: linkNode,
|
|
850
|
+
flags: { titleEnabled: shouldShowLinkTitle(editor) }
|
|
851
|
+
};
|
|
852
|
+
});
|
|
853
|
+
const DialogInfo = { collect };
|
|
894
854
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
unlink(editor);
|
|
900
|
-
api.close();
|
|
901
|
-
return;
|
|
902
|
-
}
|
|
903
|
-
var getChangedValue = function (key) {
|
|
904
|
-
return Optional.from(data[key]).filter(function (value) {
|
|
905
|
-
return !is(info.anchor[key], value);
|
|
906
|
-
});
|
|
907
|
-
};
|
|
908
|
-
var changedData = {
|
|
909
|
-
href: data.url.value,
|
|
910
|
-
text: getChangedValue('text'),
|
|
911
|
-
target: getChangedValue('target'),
|
|
912
|
-
rel: getChangedValue('rel'),
|
|
913
|
-
class: getChangedValue('linkClass'),
|
|
914
|
-
title: getChangedValue('title')
|
|
915
|
-
};
|
|
916
|
-
var attachState = {
|
|
917
|
-
href: data.url.value,
|
|
918
|
-
attach: data.url.meta !== undefined && data.url.meta.attach ? data.url.meta.attach : noop
|
|
919
|
-
};
|
|
920
|
-
DialogConfirms.preprocess(editor, changedData).then(function (pData) {
|
|
921
|
-
link(editor, attachState, pData);
|
|
922
|
-
});
|
|
855
|
+
const handleSubmit = (editor, info) => api => {
|
|
856
|
+
const data = api.getData();
|
|
857
|
+
if (!data.url.value) {
|
|
858
|
+
unlink(editor);
|
|
923
859
|
api.close();
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const getChangedValue = key => Optional.from(data[key]).filter(value => !is(info.anchor[key], value));
|
|
863
|
+
const changedData = {
|
|
864
|
+
href: data.url.value,
|
|
865
|
+
text: getChangedValue('text'),
|
|
866
|
+
target: getChangedValue('target'),
|
|
867
|
+
rel: getChangedValue('rel'),
|
|
868
|
+
class: getChangedValue('linkClass'),
|
|
869
|
+
title: getChangedValue('title')
|
|
870
|
+
};
|
|
871
|
+
const attachState = {
|
|
872
|
+
href: data.url.value,
|
|
873
|
+
attach: data.url.meta !== undefined && data.url.meta.attach ? data.url.meta.attach : noop
|
|
924
874
|
};
|
|
875
|
+
DialogConfirms.preprocess(editor, changedData).then(pData => {
|
|
876
|
+
link(editor, attachState, pData);
|
|
877
|
+
});
|
|
878
|
+
api.close();
|
|
925
879
|
};
|
|
926
|
-
|
|
927
|
-
|
|
880
|
+
const collectData = editor => {
|
|
881
|
+
const anchorNode = getAnchorElement(editor);
|
|
928
882
|
return DialogInfo.collect(editor, anchorNode);
|
|
929
883
|
};
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
884
|
+
const getInitialData = (info, defaultTarget) => {
|
|
885
|
+
const anchor = info.anchor;
|
|
886
|
+
const url = anchor.url.getOr('');
|
|
933
887
|
return {
|
|
934
888
|
url: {
|
|
935
889
|
value: url,
|
|
@@ -944,30 +898,29 @@
|
|
|
944
898
|
linkClass: anchor.linkClass.getOr('')
|
|
945
899
|
};
|
|
946
900
|
};
|
|
947
|
-
|
|
948
|
-
|
|
901
|
+
const makeDialog = (settings, onSubmit, editor) => {
|
|
902
|
+
const urlInput = [{
|
|
949
903
|
name: 'url',
|
|
950
904
|
type: 'urlinput',
|
|
951
905
|
filetype: 'file',
|
|
952
|
-
label: 'URL'
|
|
906
|
+
label: 'URL',
|
|
907
|
+
picker_text: 'Browse links'
|
|
953
908
|
}];
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}).toArray();
|
|
961
|
-
var titleText = settings.flags.titleEnabled ? [{
|
|
909
|
+
const displayText = settings.anchor.text.map(() => ({
|
|
910
|
+
name: 'text',
|
|
911
|
+
type: 'input',
|
|
912
|
+
label: 'Text to display'
|
|
913
|
+
})).toArray();
|
|
914
|
+
const titleText = settings.flags.titleEnabled ? [{
|
|
962
915
|
name: 'title',
|
|
963
916
|
type: 'input',
|
|
964
917
|
label: 'Title'
|
|
965
918
|
}] : [];
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
919
|
+
const defaultTarget = Optional.from(getDefaultLinkTarget(editor));
|
|
920
|
+
const initialData = getInitialData(settings, defaultTarget);
|
|
921
|
+
const catalogs = settings.catalogs;
|
|
922
|
+
const dialogDelta = DialogChanges.init(initialData, catalogs);
|
|
923
|
+
const body = {
|
|
971
924
|
type: 'panel',
|
|
972
925
|
items: flatten([
|
|
973
926
|
urlInput,
|
|
@@ -985,7 +938,7 @@
|
|
|
985
938
|
return {
|
|
986
939
|
title: 'Insert/Edit Link',
|
|
987
940
|
size: 'normal',
|
|
988
|
-
body
|
|
941
|
+
body,
|
|
989
942
|
buttons: [
|
|
990
943
|
{
|
|
991
944
|
type: 'cancel',
|
|
@@ -999,55 +952,62 @@
|
|
|
999
952
|
primary: true
|
|
1000
953
|
}
|
|
1001
954
|
],
|
|
1002
|
-
initialData
|
|
1003
|
-
onChange:
|
|
1004
|
-
|
|
1005
|
-
dialogDelta.onChange(api.getData, { name: name }).each(function (newData) {
|
|
955
|
+
initialData,
|
|
956
|
+
onChange: (api, {name}) => {
|
|
957
|
+
dialogDelta.onChange(api.getData, { name }).each(newData => {
|
|
1006
958
|
api.setData(newData);
|
|
1007
959
|
});
|
|
1008
960
|
},
|
|
1009
|
-
onSubmit
|
|
961
|
+
onSubmit
|
|
1010
962
|
};
|
|
1011
963
|
};
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
data.then(
|
|
1015
|
-
|
|
964
|
+
const open$1 = editor => {
|
|
965
|
+
const data = collectData(editor);
|
|
966
|
+
data.then(info => {
|
|
967
|
+
const onSubmit = handleSubmit(editor, info);
|
|
1016
968
|
return makeDialog(info, onSubmit, editor);
|
|
1017
|
-
}).then(
|
|
969
|
+
}).then(spec => {
|
|
1018
970
|
editor.windowManager.open(spec);
|
|
1019
971
|
});
|
|
1020
972
|
};
|
|
1021
973
|
|
|
1022
|
-
|
|
974
|
+
const register = editor => {
|
|
975
|
+
editor.addCommand('mceLink', (_ui, value) => {
|
|
976
|
+
if ((value === null || value === void 0 ? void 0 : value.dialog) === true || !useQuickLink(editor)) {
|
|
977
|
+
open$1(editor);
|
|
978
|
+
} else {
|
|
979
|
+
editor.dispatch('contexttoolbar-show', { toolbarKey: 'quicklink' });
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
var global = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
985
|
+
|
|
986
|
+
const appendClickRemove = (link, evt) => {
|
|
1023
987
|
document.body.appendChild(link);
|
|
1024
988
|
link.dispatchEvent(evt);
|
|
1025
989
|
document.body.removeChild(link);
|
|
1026
990
|
};
|
|
1027
|
-
|
|
1028
|
-
|
|
991
|
+
const open = url => {
|
|
992
|
+
const link = document.createElement('a');
|
|
1029
993
|
link.target = '_blank';
|
|
1030
994
|
link.href = url;
|
|
1031
995
|
link.rel = 'noreferrer noopener';
|
|
1032
|
-
|
|
996
|
+
const evt = document.createEvent('MouseEvents');
|
|
1033
997
|
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
1034
998
|
appendClickRemove(link, evt);
|
|
1035
999
|
};
|
|
1036
1000
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
var getSelectedLink = function (editor) {
|
|
1041
|
-
return getLink(editor, editor.selection.getStart());
|
|
1042
|
-
};
|
|
1043
|
-
var hasOnlyAltModifier = function (e) {
|
|
1001
|
+
const getLink = (editor, elm) => editor.dom.getParent(elm, 'a[href]');
|
|
1002
|
+
const getSelectedLink = editor => getLink(editor, editor.selection.getStart());
|
|
1003
|
+
const hasOnlyAltModifier = e => {
|
|
1044
1004
|
return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false;
|
|
1045
1005
|
};
|
|
1046
|
-
|
|
1006
|
+
const gotoLink = (editor, a) => {
|
|
1047
1007
|
if (a) {
|
|
1048
|
-
|
|
1008
|
+
const href = getHref(a);
|
|
1049
1009
|
if (/^#/.test(href)) {
|
|
1050
|
-
|
|
1010
|
+
const targetEl = editor.dom.select(href);
|
|
1051
1011
|
if (targetEl.length) {
|
|
1052
1012
|
editor.selection.scrollIntoView(targetEl[0], true);
|
|
1053
1013
|
}
|
|
@@ -1056,153 +1016,144 @@
|
|
|
1056
1016
|
}
|
|
1057
1017
|
}
|
|
1058
1018
|
};
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
open$1(editor);
|
|
1062
|
-
};
|
|
1019
|
+
const openDialog = editor => () => {
|
|
1020
|
+
editor.execCommand('mceLink', false, { dialog: true });
|
|
1063
1021
|
};
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
gotoLink(editor, getSelectedLink(editor));
|
|
1067
|
-
};
|
|
1022
|
+
const gotoSelectedLink = editor => () => {
|
|
1023
|
+
gotoLink(editor, getSelectedLink(editor));
|
|
1068
1024
|
};
|
|
1069
|
-
|
|
1070
|
-
editor.on('click',
|
|
1071
|
-
|
|
1072
|
-
if (link && global
|
|
1025
|
+
const setupGotoLinks = editor => {
|
|
1026
|
+
editor.on('click', e => {
|
|
1027
|
+
const link = getLink(editor, e.target);
|
|
1028
|
+
if (link && global.metaKeyPressed(e)) {
|
|
1073
1029
|
e.preventDefault();
|
|
1074
1030
|
gotoLink(editor, link);
|
|
1075
1031
|
}
|
|
1076
1032
|
});
|
|
1077
|
-
editor.on('keydown',
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1033
|
+
editor.on('keydown', e => {
|
|
1034
|
+
if (!e.isDefaultPrevented() && e.keyCode === 13 && hasOnlyAltModifier(e)) {
|
|
1035
|
+
const link = getSelectedLink(editor);
|
|
1036
|
+
if (link) {
|
|
1037
|
+
e.preventDefault();
|
|
1038
|
+
gotoLink(editor, link);
|
|
1039
|
+
}
|
|
1082
1040
|
}
|
|
1083
1041
|
});
|
|
1084
1042
|
};
|
|
1085
|
-
|
|
1043
|
+
const toggleState = (editor, toggler) => {
|
|
1086
1044
|
editor.on('NodeChange', toggler);
|
|
1087
|
-
return
|
|
1088
|
-
return editor.off('NodeChange', toggler);
|
|
1089
|
-
};
|
|
1045
|
+
return () => editor.off('NodeChange', toggler);
|
|
1090
1046
|
};
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
};
|
|
1096
|
-
updateState();
|
|
1097
|
-
return toggleState(editor, updateState);
|
|
1047
|
+
const toggleLinkState = editor => api => {
|
|
1048
|
+
const updateState = () => {
|
|
1049
|
+
api.setActive(!editor.mode.isReadOnly() && isInAnchor(editor, editor.selection.getNode()));
|
|
1050
|
+
api.setEnabled(editor.selection.isEditable());
|
|
1098
1051
|
};
|
|
1052
|
+
updateState();
|
|
1053
|
+
return toggleState(editor, updateState);
|
|
1099
1054
|
};
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
return api.setDisabled(getAnchorElement(editor, editor.selection.getNode()) === null);
|
|
1104
|
-
};
|
|
1105
|
-
updateState();
|
|
1106
|
-
return toggleState(editor, updateState);
|
|
1055
|
+
const toggleLinkMenuState = editor => api => {
|
|
1056
|
+
const updateState = () => {
|
|
1057
|
+
api.setEnabled(editor.selection.isEditable());
|
|
1107
1058
|
};
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1059
|
+
updateState();
|
|
1060
|
+
return toggleState(editor, updateState);
|
|
1061
|
+
};
|
|
1062
|
+
const hasExactlyOneLinkInSelection = editor => {
|
|
1063
|
+
const links = editor.selection.isCollapsed() ? getLinks$1(editor.dom.getParents(editor.selection.getStart())) : getLinksInSelection(editor.selection.getRng());
|
|
1064
|
+
return links.length === 1;
|
|
1065
|
+
};
|
|
1066
|
+
const toggleGotoLinkState = editor => api => {
|
|
1067
|
+
const updateState = () => api.setEnabled(hasExactlyOneLinkInSelection(editor));
|
|
1068
|
+
updateState();
|
|
1069
|
+
return toggleState(editor, updateState);
|
|
1070
|
+
};
|
|
1071
|
+
const toggleUnlinkState = editor => api => {
|
|
1072
|
+
const hasLinks$1 = parents => hasLinks(parents) || hasLinksInSelection(editor.selection.getRng());
|
|
1073
|
+
const parents = editor.dom.getParents(editor.selection.getStart());
|
|
1074
|
+
const updateEnabled = parents => {
|
|
1075
|
+
api.setEnabled(hasLinks$1(parents) && editor.selection.isEditable());
|
|
1119
1076
|
};
|
|
1077
|
+
updateEnabled(parents);
|
|
1078
|
+
return toggleState(editor, e => updateEnabled(e.parents));
|
|
1120
1079
|
};
|
|
1121
1080
|
|
|
1122
|
-
|
|
1123
|
-
editor.
|
|
1124
|
-
if (useQuickLink(editor)) {
|
|
1125
|
-
editor.fire('contexttoolbar-show', { toolbarKey: 'quicklink' });
|
|
1126
|
-
} else {
|
|
1127
|
-
openDialog(editor)();
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
};
|
|
1131
|
-
|
|
1132
|
-
var setup = function (editor) {
|
|
1133
|
-
editor.addShortcut('Meta+K', '', function () {
|
|
1081
|
+
const setup = editor => {
|
|
1082
|
+
editor.addShortcut('Meta+K', '', () => {
|
|
1134
1083
|
editor.execCommand('mceLink');
|
|
1135
1084
|
});
|
|
1136
1085
|
};
|
|
1137
1086
|
|
|
1138
|
-
|
|
1087
|
+
const setupButtons = editor => {
|
|
1139
1088
|
editor.ui.registry.addToggleButton('link', {
|
|
1140
1089
|
icon: 'link',
|
|
1141
1090
|
tooltip: 'Insert/edit link',
|
|
1142
1091
|
onAction: openDialog(editor),
|
|
1143
|
-
onSetup:
|
|
1092
|
+
onSetup: toggleLinkState(editor),
|
|
1093
|
+
shortcut: 'Meta+K'
|
|
1144
1094
|
});
|
|
1145
1095
|
editor.ui.registry.addButton('openlink', {
|
|
1146
1096
|
icon: 'new-tab',
|
|
1147
1097
|
tooltip: 'Open link',
|
|
1148
1098
|
onAction: gotoSelectedLink(editor),
|
|
1149
|
-
onSetup:
|
|
1099
|
+
onSetup: toggleGotoLinkState(editor)
|
|
1150
1100
|
});
|
|
1151
1101
|
editor.ui.registry.addButton('unlink', {
|
|
1152
1102
|
icon: 'unlink',
|
|
1153
1103
|
tooltip: 'Remove link',
|
|
1154
|
-
onAction:
|
|
1155
|
-
return unlink(editor);
|
|
1156
|
-
},
|
|
1104
|
+
onAction: () => unlink(editor),
|
|
1157
1105
|
onSetup: toggleUnlinkState(editor)
|
|
1158
1106
|
});
|
|
1159
1107
|
};
|
|
1160
|
-
|
|
1108
|
+
const setupMenuItems = editor => {
|
|
1161
1109
|
editor.ui.registry.addMenuItem('openlink', {
|
|
1162
1110
|
text: 'Open link',
|
|
1163
1111
|
icon: 'new-tab',
|
|
1164
1112
|
onAction: gotoSelectedLink(editor),
|
|
1165
|
-
onSetup:
|
|
1113
|
+
onSetup: toggleGotoLinkState(editor)
|
|
1166
1114
|
});
|
|
1167
1115
|
editor.ui.registry.addMenuItem('link', {
|
|
1168
1116
|
icon: 'link',
|
|
1169
1117
|
text: 'Link...',
|
|
1170
1118
|
shortcut: 'Meta+K',
|
|
1119
|
+
onSetup: toggleLinkMenuState(editor),
|
|
1171
1120
|
onAction: openDialog(editor)
|
|
1172
1121
|
});
|
|
1173
1122
|
editor.ui.registry.addMenuItem('unlink', {
|
|
1174
1123
|
icon: 'unlink',
|
|
1175
1124
|
text: 'Remove link',
|
|
1176
|
-
onAction:
|
|
1177
|
-
return unlink(editor);
|
|
1178
|
-
},
|
|
1125
|
+
onAction: () => unlink(editor),
|
|
1179
1126
|
onSetup: toggleUnlinkState(editor)
|
|
1180
1127
|
});
|
|
1181
1128
|
};
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1129
|
+
const setupContextMenu = editor => {
|
|
1130
|
+
const inLink = 'link unlink openlink';
|
|
1131
|
+
const noLink = 'link';
|
|
1185
1132
|
editor.ui.registry.addContextMenu('link', {
|
|
1186
|
-
update:
|
|
1133
|
+
update: element => {
|
|
1134
|
+
const isEditable = editor.dom.isEditable(element);
|
|
1135
|
+
if (!isEditable) {
|
|
1136
|
+
return '';
|
|
1137
|
+
}
|
|
1187
1138
|
return hasLinks(editor.dom.getParents(element, 'a')) ? inLink : noLink;
|
|
1188
1139
|
}
|
|
1189
1140
|
});
|
|
1190
1141
|
};
|
|
1191
|
-
|
|
1192
|
-
|
|
1142
|
+
const setupContextToolbars = editor => {
|
|
1143
|
+
const collapseSelectionToEnd = editor => {
|
|
1193
1144
|
editor.selection.collapse(false);
|
|
1194
1145
|
};
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
buttonApi.
|
|
1146
|
+
const onSetupLink = buttonApi => {
|
|
1147
|
+
const node = editor.selection.getNode();
|
|
1148
|
+
buttonApi.setEnabled(isInAnchor(editor, node));
|
|
1198
1149
|
return noop;
|
|
1199
1150
|
};
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
if (
|
|
1204
|
-
|
|
1205
|
-
return
|
|
1151
|
+
const getLinkText = value => {
|
|
1152
|
+
const anchor = getAnchorElement(editor);
|
|
1153
|
+
const onlyText = isOnlyTextSelected(editor);
|
|
1154
|
+
if (anchor.isNone() && onlyText) {
|
|
1155
|
+
const text = getAnchorText(editor.selection, anchor);
|
|
1156
|
+
return someIf(text.length === 0, value);
|
|
1206
1157
|
} else {
|
|
1207
1158
|
return Optional.none();
|
|
1208
1159
|
}
|
|
@@ -1212,15 +1163,13 @@
|
|
|
1212
1163
|
type: 'contextformtogglebutton',
|
|
1213
1164
|
icon: 'link',
|
|
1214
1165
|
tooltip: 'Link',
|
|
1215
|
-
onSetup:
|
|
1166
|
+
onSetup: toggleLinkState(editor)
|
|
1216
1167
|
},
|
|
1217
1168
|
label: 'Link',
|
|
1218
|
-
predicate:
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
var elm = getAnchorElement(editor);
|
|
1223
|
-
return !!elm ? getHref(elm) : '';
|
|
1169
|
+
predicate: node => hasContextToolbar(editor) && isInAnchor(editor, node),
|
|
1170
|
+
initValue: () => {
|
|
1171
|
+
const elm = getAnchorElement(editor);
|
|
1172
|
+
return elm.fold(constant(''), getHref);
|
|
1224
1173
|
},
|
|
1225
1174
|
commands: [
|
|
1226
1175
|
{
|
|
@@ -1228,24 +1177,24 @@
|
|
|
1228
1177
|
icon: 'link',
|
|
1229
1178
|
tooltip: 'Link',
|
|
1230
1179
|
primary: true,
|
|
1231
|
-
onSetup:
|
|
1232
|
-
|
|
1233
|
-
buttonApi.setActive(
|
|
1234
|
-
return
|
|
1180
|
+
onSetup: buttonApi => {
|
|
1181
|
+
const node = editor.selection.getNode();
|
|
1182
|
+
buttonApi.setActive(isInAnchor(editor, node));
|
|
1183
|
+
return toggleLinkState(editor)(buttonApi);
|
|
1235
1184
|
},
|
|
1236
|
-
onAction:
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1185
|
+
onAction: formApi => {
|
|
1186
|
+
const value = formApi.getValue();
|
|
1187
|
+
const text = getLinkText(value);
|
|
1188
|
+
const attachState = {
|
|
1240
1189
|
href: value,
|
|
1241
1190
|
attach: noop
|
|
1242
1191
|
};
|
|
1243
1192
|
link(editor, attachState, {
|
|
1244
1193
|
href: value,
|
|
1245
|
-
text
|
|
1194
|
+
text,
|
|
1246
1195
|
title: Optional.none(),
|
|
1247
1196
|
rel: Optional.none(),
|
|
1248
|
-
target: Optional.
|
|
1197
|
+
target: Optional.from(getDefaultLinkTarget(editor)),
|
|
1249
1198
|
class: Optional.none()
|
|
1250
1199
|
});
|
|
1251
1200
|
collapseSelectionToEnd(editor);
|
|
@@ -1257,7 +1206,7 @@
|
|
|
1257
1206
|
icon: 'unlink',
|
|
1258
1207
|
tooltip: 'Remove link',
|
|
1259
1208
|
onSetup: onSetupLink,
|
|
1260
|
-
onAction:
|
|
1209
|
+
onAction: formApi => {
|
|
1261
1210
|
unlink(editor);
|
|
1262
1211
|
formApi.hide();
|
|
1263
1212
|
}
|
|
@@ -1267,7 +1216,7 @@
|
|
|
1267
1216
|
icon: 'new-tab',
|
|
1268
1217
|
tooltip: 'Open link',
|
|
1269
1218
|
onSetup: onSetupLink,
|
|
1270
|
-
onAction:
|
|
1219
|
+
onAction: formApi => {
|
|
1271
1220
|
gotoSelectedLink(editor)();
|
|
1272
1221
|
formApi.hide();
|
|
1273
1222
|
}
|
|
@@ -1276,8 +1225,9 @@
|
|
|
1276
1225
|
});
|
|
1277
1226
|
};
|
|
1278
1227
|
|
|
1279
|
-
|
|
1280
|
-
global$
|
|
1228
|
+
var Plugin = () => {
|
|
1229
|
+
global$5.add('link', editor => {
|
|
1230
|
+
register$1(editor);
|
|
1281
1231
|
setupButtons(editor);
|
|
1282
1232
|
setupMenuItems(editor);
|
|
1283
1233
|
setupContextMenu(editor);
|
|
@@ -1286,8 +1236,8 @@
|
|
|
1286
1236
|
register(editor);
|
|
1287
1237
|
setup(editor);
|
|
1288
1238
|
});
|
|
1289
|
-
}
|
|
1239
|
+
};
|
|
1290
1240
|
|
|
1291
1241
|
Plugin();
|
|
1292
1242
|
|
|
1293
|
-
}()
|
|
1243
|
+
})();
|