@ckeditor/ckeditor5-link 47.6.1 → 48.0.0-alpha.0
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/LICENSE.md +1 -1
- package/ckeditor5-metadata.json +6 -6
- package/{src → dist}/autolink.d.ts +2 -2
- package/dist/index-editor.css +181 -105
- package/dist/index.css +169 -151
- package/dist/index.css.map +1 -1
- package/{src → dist}/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/{src → dist}/link.d.ts +1 -1
- package/{src → dist}/linkcommand.d.ts +2 -2
- package/{src → dist}/linkconfig.d.ts +1 -1
- package/{src → dist}/linkediting.d.ts +3 -3
- package/{src → dist}/linkimage.d.ts +1 -1
- package/{src → dist}/linkimageediting.d.ts +3 -2
- package/{src → dist}/linkimageui.d.ts +3 -2
- package/{src → dist}/linkui.d.ts +2 -2
- package/{src → dist}/ui/linkbuttonview.d.ts +2 -2
- package/{src → dist}/ui/linkformview.d.ts +2 -4
- package/{src → dist}/ui/linkpreviewbuttonview.d.ts +2 -2
- package/{src → dist}/ui/linkpropertiesview.d.ts +2 -2
- package/{src → dist}/ui/linkprovideritemsview.d.ts +2 -2
- package/{src → dist}/unlinkcommand.d.ts +1 -1
- package/{src → dist}/utils/automaticdecorators.d.ts +2 -2
- package/{src → dist}/utils/manualdecorator.d.ts +4 -4
- package/{src → dist}/utils.d.ts +2 -2
- package/package.json +29 -52
- package/build/link.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -16
- package/lang/translations/af.po +0 -68
- package/lang/translations/ar.po +0 -68
- package/lang/translations/ast.po +0 -68
- package/lang/translations/az.po +0 -68
- package/lang/translations/be.po +0 -68
- package/lang/translations/bg.po +0 -68
- package/lang/translations/bn.po +0 -70
- package/lang/translations/bs.po +0 -68
- package/lang/translations/ca.po +0 -68
- package/lang/translations/cs.po +0 -68
- package/lang/translations/da.po +0 -68
- package/lang/translations/de-ch.po +0 -68
- package/lang/translations/de.po +0 -68
- package/lang/translations/el.po +0 -68
- package/lang/translations/en-au.po +0 -68
- package/lang/translations/en-gb.po +0 -68
- package/lang/translations/en.po +0 -68
- package/lang/translations/eo.po +0 -68
- package/lang/translations/es-co.po +0 -68
- package/lang/translations/es.po +0 -68
- package/lang/translations/et.po +0 -68
- package/lang/translations/eu.po +0 -68
- package/lang/translations/fa.po +0 -68
- package/lang/translations/fi.po +0 -68
- package/lang/translations/fr.po +0 -68
- package/lang/translations/gl.po +0 -68
- package/lang/translations/gu.po +0 -68
- package/lang/translations/he.po +0 -68
- package/lang/translations/hi.po +0 -68
- package/lang/translations/hr.po +0 -68
- package/lang/translations/hu.po +0 -68
- package/lang/translations/hy.po +0 -68
- package/lang/translations/id.po +0 -68
- package/lang/translations/it.po +0 -68
- package/lang/translations/ja.po +0 -68
- package/lang/translations/jv.po +0 -68
- package/lang/translations/kk.po +0 -68
- package/lang/translations/km.po +0 -68
- package/lang/translations/kn.po +0 -68
- package/lang/translations/ko.po +0 -68
- package/lang/translations/ku.po +0 -68
- package/lang/translations/lt.po +0 -68
- package/lang/translations/lv.po +0 -68
- package/lang/translations/ms.po +0 -68
- package/lang/translations/nb.po +0 -68
- package/lang/translations/ne.po +0 -68
- package/lang/translations/nl.po +0 -68
- package/lang/translations/no.po +0 -68
- package/lang/translations/oc.po +0 -68
- package/lang/translations/pl.po +0 -68
- package/lang/translations/pt-br.po +0 -68
- package/lang/translations/pt.po +0 -68
- package/lang/translations/ro.po +0 -68
- package/lang/translations/ru.po +0 -68
- package/lang/translations/si.po +0 -68
- package/lang/translations/sk.po +0 -68
- package/lang/translations/sl.po +0 -68
- package/lang/translations/sq.po +0 -68
- package/lang/translations/sr-latn.po +0 -68
- package/lang/translations/sr.po +0 -68
- package/lang/translations/sv.po +0 -68
- package/lang/translations/th.po +0 -68
- package/lang/translations/ti.po +0 -68
- package/lang/translations/tk.po +0 -68
- package/lang/translations/tr.po +0 -68
- package/lang/translations/tt.po +0 -68
- package/lang/translations/ug.po +0 -68
- package/lang/translations/uk.po +0 -68
- package/lang/translations/ur.po +0 -68
- package/lang/translations/uz.po +0 -68
- package/lang/translations/vi.po +0 -68
- package/lang/translations/zh-cn.po +0 -68
- package/lang/translations/zh.po +0 -68
- package/src/augmentation.js +0 -5
- package/src/autolink.js +0 -307
- package/src/index.js +0 -25
- package/src/link.js +0 -37
- package/src/linkcommand.js +0 -431
- package/src/linkconfig.js +0 -5
- package/src/linkediting.js +0 -402
- package/src/linkimage.js +0 -37
- package/src/linkimageediting.js +0 -264
- package/src/linkimageui.js +0 -102
- package/src/linkui.js +0 -1072
- package/src/ui/linkbuttonview.js +0 -54
- package/src/ui/linkformview.js +0 -302
- package/src/ui/linkpreviewbuttonview.js +0 -43
- package/src/ui/linkpropertiesview.js +0 -170
- package/src/ui/linkprovideritemsview.js +0 -207
- package/src/unlinkcommand.js +0 -66
- package/src/utils/automaticdecorators.js +0 -181
- package/src/utils/conflictingdecorators.js +0 -80
- package/src/utils/manualdecorator.js +0 -69
- package/src/utils.js +0 -157
- package/theme/link.css +0 -10
- package/theme/linkform.css +0 -24
- package/theme/linkimage.css +0 -16
- package/theme/linkproperties.css +0 -4
- package/theme/linkprovideritems.css +0 -18
- package/theme/linktoolbar.css +0 -12
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/utils/conflictingdecorators.d.ts +0 -0
package/src/utils.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { upperFirst } from 'es-toolkit/compat';
|
|
6
|
-
const ATTRIBUTE_WHITESPACES = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex
|
|
7
|
-
const SAFE_URL_TEMPLATE = '^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))';
|
|
8
|
-
// Simplified email test - should be run over previously found URL.
|
|
9
|
-
const EMAIL_REG_EXP = /^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i;
|
|
10
|
-
// The regex checks for the protocol syntax ('xxxx://' or 'xxxx:')
|
|
11
|
-
// or non-word characters at the beginning of the link ('/', '#' etc.).
|
|
12
|
-
const PROTOCOL_REG_EXP = /^((\w+:(\/{2,})?)|(\W))/i;
|
|
13
|
-
const DEFAULT_LINK_PROTOCOLS = [
|
|
14
|
-
'https?',
|
|
15
|
-
'ftps?',
|
|
16
|
-
'mailto'
|
|
17
|
-
];
|
|
18
|
-
/**
|
|
19
|
-
* A keystroke used by the {@link module:link/linkui~LinkUI link UI feature}.
|
|
20
|
-
*/
|
|
21
|
-
export const LINK_KEYSTROKE = 'Ctrl+K';
|
|
22
|
-
/**
|
|
23
|
-
* Returns `true` if a given view node is the link element.
|
|
24
|
-
*/
|
|
25
|
-
export function isLinkElement(node) {
|
|
26
|
-
return node.is('attributeElement') && !!node.getCustomProperty('link');
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Creates a link {@link module:engine/view/attributeelement~ViewAttributeElement} with the provided `href` attribute.
|
|
30
|
-
*/
|
|
31
|
-
export function createLinkElement(href, { writer }) {
|
|
32
|
-
// Priority 5 - https://github.com/ckeditor/ckeditor5-link/issues/121.
|
|
33
|
-
const linkElement = writer.createAttributeElement('a', { href }, { priority: 5 });
|
|
34
|
-
writer.setCustomProperty('link', true, linkElement);
|
|
35
|
-
return linkElement;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Returns a safe URL based on a given value.
|
|
39
|
-
*
|
|
40
|
-
* A URL is considered safe if it is safe for the user (does not contain any malicious code).
|
|
41
|
-
*
|
|
42
|
-
* If a URL is considered unsafe, a simple `"#"` is returned.
|
|
43
|
-
*
|
|
44
|
-
* @internal
|
|
45
|
-
*/
|
|
46
|
-
export function ensureSafeUrl(url, allowedProtocols = DEFAULT_LINK_PROTOCOLS) {
|
|
47
|
-
const urlString = String(url);
|
|
48
|
-
const protocolsList = allowedProtocols.join('|');
|
|
49
|
-
const customSafeRegex = new RegExp(`${SAFE_URL_TEMPLATE.replace('<protocols>', protocolsList)}`, 'i');
|
|
50
|
-
return isSafeUrl(urlString, customSafeRegex) ? urlString : '#';
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Checks whether the given URL is safe for the user (does not contain any malicious code).
|
|
54
|
-
*/
|
|
55
|
-
function isSafeUrl(url, customRegexp) {
|
|
56
|
-
const normalizedUrl = url.replace(ATTRIBUTE_WHITESPACES, '');
|
|
57
|
-
return !!normalizedUrl.match(customRegexp);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration processed
|
|
61
|
-
* to respect the locale of the editor, i.e. to display the {@link module:link/linkconfig~LinkDecoratorManualDefinition label}
|
|
62
|
-
* in the correct language.
|
|
63
|
-
*
|
|
64
|
-
* **Note**: Only the few most commonly used labels are translated automatically. Other labels should be manually
|
|
65
|
-
* translated in the {@link module:link/linkconfig~LinkConfig#decorators `config.link.decorators`} configuration.
|
|
66
|
-
*
|
|
67
|
-
* @param t Shorthand for {@link module:utils/locale~Locale#t Locale#t}.
|
|
68
|
-
* @param decorators The decorator reference where the label values should be localized.
|
|
69
|
-
* @internal
|
|
70
|
-
*/
|
|
71
|
-
export function getLocalizedDecorators(t, decorators) {
|
|
72
|
-
const localizedDecoratorsLabels = {
|
|
73
|
-
'Open in a new tab': t('Open in a new tab'),
|
|
74
|
-
'Downloadable': t('Downloadable')
|
|
75
|
-
};
|
|
76
|
-
decorators.forEach(decorator => {
|
|
77
|
-
if ('label' in decorator && localizedDecoratorsLabels[decorator.label]) {
|
|
78
|
-
decorator.label = localizedDecoratorsLabels[decorator.label];
|
|
79
|
-
}
|
|
80
|
-
return decorator;
|
|
81
|
-
});
|
|
82
|
-
return decorators;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Converts an object with defined decorators to a normalized array of decorators. The `id` key is added for each decorator and
|
|
86
|
-
* is used as the attribute's name in the model.
|
|
87
|
-
*
|
|
88
|
-
* @internal
|
|
89
|
-
*/
|
|
90
|
-
export function normalizeDecorators(decorators) {
|
|
91
|
-
const retArray = [];
|
|
92
|
-
if (decorators) {
|
|
93
|
-
for (const [key, value] of Object.entries(decorators)) {
|
|
94
|
-
const decorator = Object.assign({}, value, { id: `link${upperFirst(key)}` });
|
|
95
|
-
retArray.push(decorator);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return retArray;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Returns `true` if the specified `element` can be linked (the element allows the `linkHref` attribute).
|
|
102
|
-
*/
|
|
103
|
-
export function isLinkableElement(element, schema) {
|
|
104
|
-
if (!element) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return schema.checkAttribute(element.name, 'linkHref');
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Returns `true` if the specified `value` is an email.
|
|
111
|
-
*
|
|
112
|
-
* @internal
|
|
113
|
-
*/
|
|
114
|
-
export function isEmail(value) {
|
|
115
|
-
return EMAIL_REG_EXP.test(value);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Adds the protocol prefix to the specified `link` when:
|
|
119
|
-
*
|
|
120
|
-
* * it does not contain it already, and there is a {@link module:link/linkconfig~LinkConfig#defaultProtocol `defaultProtocol` }
|
|
121
|
-
* configuration value provided,
|
|
122
|
-
* * or the link is an email address.
|
|
123
|
-
*/
|
|
124
|
-
export function addLinkProtocolIfApplicable(link, defaultProtocol) {
|
|
125
|
-
const protocol = isEmail(link) ? 'mailto:' : defaultProtocol;
|
|
126
|
-
const isProtocolNeeded = !!protocol && !linkHasProtocol(link);
|
|
127
|
-
return link && isProtocolNeeded ? protocol + link : link;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Checks if protocol is already included in the link.
|
|
131
|
-
*
|
|
132
|
-
* @internal
|
|
133
|
-
*/
|
|
134
|
-
export function linkHasProtocol(link) {
|
|
135
|
-
return PROTOCOL_REG_EXP.test(link);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Opens the link in a new browser tab.
|
|
139
|
-
*/
|
|
140
|
-
export function openLink(link) {
|
|
141
|
-
window.open(link, '_blank', 'noopener');
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Returns a text of a link range.
|
|
145
|
-
*
|
|
146
|
-
* If the returned value is `undefined`, the range contains elements other than text nodes.
|
|
147
|
-
*/
|
|
148
|
-
export function extractTextFromLinkRange(range) {
|
|
149
|
-
let text = '';
|
|
150
|
-
for (const item of range.getItems()) {
|
|
151
|
-
if (!item.is('$text') && !item.is('$textProxy')) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
text += item.data;
|
|
155
|
-
}
|
|
156
|
-
return text;
|
|
157
|
-
}
|
package/theme/link.css
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Note: This file should contain the wireframe styles only. But since there are no such styles,
|
|
8
|
-
* it acts as a message to the builder telling that it should look for the corresponding styles
|
|
9
|
-
* **in the theme** when compiling the editor.
|
|
10
|
-
*/
|
package/theme/linkform.css
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
|
7
|
-
|
|
8
|
-
/* Generic class that wraps each link balloon view. */
|
|
9
|
-
.ck.ck-link-form {
|
|
10
|
-
& .ck-link-form__providers-list {
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
|
|
14
|
-
& .ck-link__button {
|
|
15
|
-
& > .ck-button__label {
|
|
16
|
-
flex-grow: 1;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
& .ck-link__items:empty {
|
|
22
|
-
display: none;
|
|
23
|
-
}
|
|
24
|
-
}
|
package/theme/linkimage.css
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
.ck.ck-editor__editable {
|
|
7
|
-
/* Linked image indicator */
|
|
8
|
-
& figure.image > a,
|
|
9
|
-
& a span.image-inline {
|
|
10
|
-
&::after {
|
|
11
|
-
display: block;
|
|
12
|
-
position: absolute;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
package/theme/linkproperties.css
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
.ck.ck-link-providers {
|
|
7
|
-
& > .ck-link-providers__list {
|
|
8
|
-
overflow-x: hidden;
|
|
9
|
-
overflow-y: auto;
|
|
10
|
-
overscroll-behavior: contain;
|
|
11
|
-
|
|
12
|
-
& .ck-button {
|
|
13
|
-
& > .ck-icon {
|
|
14
|
-
flex-shrink: 0;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
package/theme/linktoolbar.css
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
.ck.ck-link-toolbar__preview {
|
|
7
|
-
display: inline-block;
|
|
8
|
-
|
|
9
|
-
& .ck-button__label {
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|