@ckeditor/ckeditor5-link 44.3.0-alpha.7 → 45.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/build/link.js +2 -2
- package/build/translations/af.js +1 -1
- package/build/translations/ar.js +1 -1
- package/build/translations/ast.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/be.js +1 -0
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/eo.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/eu.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/gu.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/hy.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/kk.js +1 -1
- package/build/translations/km.js +1 -1
- package/build/translations/kn.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/oc.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/si.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sl.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/ti.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/tt.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +2 -2
- package/dist/index-editor.css +87 -47
- package/dist/index.css +108 -58
- package/dist/index.css.map +1 -1
- package/dist/index.js +1161 -425
- package/dist/index.js.map +1 -1
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +1 -1
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +1 -1
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +1 -1
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +1 -1
- package/dist/translations/be.d.ts +8 -0
- package/dist/translations/be.js +5 -0
- package/dist/translations/be.umd.js +11 -0
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +1 -1
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +1 -1
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +1 -1
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +1 -1
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +1 -1
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +1 -1
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +1 -1
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +1 -1
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +1 -1
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +1 -1
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +1 -1
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +1 -1
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +1 -1
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +1 -1
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +1 -1
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +1 -1
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +1 -1
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +1 -1
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +1 -1
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +1 -1
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +1 -1
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +1 -1
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +1 -1
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +1 -1
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +1 -1
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +1 -1
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +1 -1
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +1 -1
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +1 -1
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +1 -1
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +1 -1
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +1 -1
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +1 -1
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +1 -1
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +1 -1
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +1 -1
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +1 -1
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +1 -1
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +1 -1
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +1 -1
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +1 -1
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +1 -1
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +1 -1
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +1 -1
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +1 -1
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +1 -1
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +1 -1
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +1 -1
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +1 -1
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +1 -1
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +1 -1
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +1 -1
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +1 -1
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +1 -1
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +1 -1
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +1 -1
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +1 -1
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +1 -1
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +1 -1
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +1 -1
- package/lang/contexts.json +4 -3
- package/lang/translations/af.po +10 -6
- package/lang/translations/ar.po +11 -7
- package/lang/translations/ast.po +10 -6
- package/lang/translations/az.po +10 -6
- package/lang/translations/be.po +68 -0
- package/lang/translations/bg.po +11 -7
- package/lang/translations/bn.po +11 -7
- package/lang/translations/bs.po +10 -6
- package/lang/translations/ca.po +11 -7
- package/lang/translations/cs.po +11 -7
- package/lang/translations/da.po +11 -7
- package/lang/translations/de-ch.po +10 -6
- package/lang/translations/de.po +11 -7
- package/lang/translations/el.po +11 -7
- package/lang/translations/en-au.po +11 -7
- package/lang/translations/en-gb.po +11 -7
- package/lang/translations/en.po +11 -7
- package/lang/translations/eo.po +10 -6
- package/lang/translations/es-co.po +10 -6
- package/lang/translations/es.po +11 -7
- package/lang/translations/et.po +11 -7
- package/lang/translations/eu.po +10 -6
- package/lang/translations/fa.po +10 -6
- package/lang/translations/fi.po +11 -7
- package/lang/translations/fr.po +11 -7
- package/lang/translations/gl.po +10 -6
- package/lang/translations/gu.po +10 -6
- package/lang/translations/he.po +11 -7
- package/lang/translations/hi.po +11 -7
- package/lang/translations/hr.po +10 -6
- package/lang/translations/hu.po +11 -7
- package/lang/translations/hy.po +10 -6
- package/lang/translations/id.po +11 -7
- package/lang/translations/it.po +11 -7
- package/lang/translations/ja.po +11 -7
- package/lang/translations/jv.po +10 -6
- package/lang/translations/kk.po +10 -6
- package/lang/translations/km.po +10 -6
- package/lang/translations/kn.po +10 -6
- package/lang/translations/ko.po +11 -7
- package/lang/translations/ku.po +10 -6
- package/lang/translations/lt.po +11 -7
- package/lang/translations/lv.po +11 -7
- package/lang/translations/ms.po +11 -7
- package/lang/translations/nb.po +10 -6
- package/lang/translations/ne.po +10 -6
- package/lang/translations/nl.po +11 -7
- package/lang/translations/no.po +11 -7
- package/lang/translations/oc.po +10 -6
- package/lang/translations/pl.po +11 -7
- package/lang/translations/pt-br.po +11 -7
- package/lang/translations/pt.po +11 -7
- package/lang/translations/ro.po +11 -7
- package/lang/translations/ru.po +11 -7
- package/lang/translations/si.po +10 -6
- package/lang/translations/sk.po +11 -7
- package/lang/translations/sl.po +10 -6
- package/lang/translations/sq.po +10 -6
- package/lang/translations/sr-latn.po +10 -6
- package/lang/translations/sr.po +11 -7
- package/lang/translations/sv.po +11 -7
- package/lang/translations/th.po +11 -7
- package/lang/translations/ti.po +10 -6
- package/lang/translations/tk.po +10 -6
- package/lang/translations/tr.po +11 -7
- package/lang/translations/tt.po +10 -6
- package/lang/translations/ug.po +10 -6
- package/lang/translations/uk.po +11 -7
- package/lang/translations/ur.po +10 -6
- package/lang/translations/uz.po +10 -6
- package/lang/translations/vi.po +11 -7
- package/lang/translations/zh-cn.po +11 -7
- package/lang/translations/zh.po +11 -7
- package/package.json +12 -12
- package/src/autolink.js +3 -0
- package/src/index.d.ts +1 -2
- package/src/index.js +0 -1
- package/src/linkcommand.d.ts +17 -10
- package/src/linkcommand.js +212 -82
- package/src/linkconfig.d.ts +28 -0
- package/src/linkediting.d.ts +18 -0
- package/src/linkediting.js +19 -9
- package/src/linkimageui.d.ts +1 -1
- package/src/linkimageui.js +4 -4
- package/src/linkui.d.ts +215 -24
- package/src/linkui.js +517 -109
- package/src/ui/linkbuttonview.d.ts +31 -0
- package/src/ui/linkbuttonview.js +54 -0
- package/src/ui/linkformview.d.ts +34 -49
- package/src/ui/linkformview.js +163 -134
- package/src/ui/linkpreviewbuttonview.d.ts +35 -0
- package/src/ui/linkpreviewbuttonview.js +43 -0
- package/src/ui/linkpropertiesview.d.ts +88 -0
- package/src/ui/linkpropertiesview.js +170 -0
- package/src/ui/linkprovideritemsview.d.ts +114 -0
- package/src/ui/linkprovideritemsview.js +207 -0
- package/src/utils/automaticdecorators.js +5 -7
- package/src/utils/manualdecorator.js +27 -0
- package/src/utils.d.ts +5 -5
- package/src/utils.js +12 -32
- package/theme/linkform.css +11 -33
- package/theme/linkproperties.css +4 -0
- package/theme/linkprovideritems.css +18 -0
- package/theme/linktoolbar.css +12 -0
- package/src/ui/linkactionsview.d.ts +0 -117
- package/src/ui/linkactionsview.js +0 -173
- package/theme/icons/link.svg +0 -1
- package/theme/icons/unlink.svg +0 -1
- package/theme/linkactions.css +0 -32
package/src/utils.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
4
|
*/
|
|
5
|
-
import { upperFirst } from '
|
|
5
|
+
import { upperFirst } from 'es-toolkit/compat';
|
|
6
6
|
const ATTRIBUTE_WHITESPACES = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g; // eslint-disable-line no-control-regex
|
|
7
7
|
const SAFE_URL_TEMPLATE = '^(?:(?:<protocols>):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))';
|
|
8
8
|
// Simplified email test - should be run over previously found URL.
|
|
@@ -134,37 +134,17 @@ export function openLink(link) {
|
|
|
134
134
|
window.open(link, '_blank', 'noopener');
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
*
|
|
137
|
+
* Returns a text of a link range.
|
|
138
|
+
*
|
|
139
|
+
* If the returned value is `undefined`, the range contains elements other than text nodes.
|
|
138
140
|
*/
|
|
139
|
-
export function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
function isScrollableToTarget(link) {
|
|
147
|
-
return !!link &&
|
|
148
|
-
link.startsWith('#') &&
|
|
149
|
-
!!bookmarkEditing &&
|
|
150
|
-
!!bookmarkEditing.getElementForBookmarkId(link.slice(1));
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Scrolls the view to the desired bookmark or open a link in new window.
|
|
154
|
-
*/
|
|
155
|
-
function scrollToTarget(link) {
|
|
156
|
-
const bookmarkId = link.slice(1);
|
|
157
|
-
const modelBookmark = bookmarkEditing.getElementForBookmarkId(bookmarkId);
|
|
158
|
-
editor.model.change(writer => {
|
|
159
|
-
writer.setSelection(modelBookmark, 'on');
|
|
160
|
-
});
|
|
161
|
-
editor.editing.view.scrollToTheSelection({
|
|
162
|
-
alignToTop: true,
|
|
163
|
-
forceScroll: true
|
|
164
|
-
});
|
|
141
|
+
export function extractTextFromLinkRange(range) {
|
|
142
|
+
let text = '';
|
|
143
|
+
for (const item of range.getItems()) {
|
|
144
|
+
if (!item.is('$text') && !item.is('$textProxy')) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
text += item.data;
|
|
165
148
|
}
|
|
166
|
-
return
|
|
167
|
-
isScrollableToTarget,
|
|
168
|
-
scrollToTarget
|
|
169
|
-
};
|
|
149
|
+
return text;
|
|
170
150
|
}
|
package/theme/linkform.css
CHANGED
|
@@ -5,42 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
|
7
7
|
|
|
8
|
+
/* Generic class that wraps each link balloon view. */
|
|
8
9
|
.ck.ck-link-form {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
flex-wrap: wrap;
|
|
18
|
-
|
|
19
|
-
& .ck-labeled-field-view {
|
|
20
|
-
flex-basis: 100%;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
& .ck-button {
|
|
24
|
-
flex-basis: 50%;
|
|
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
|
+
}
|
|
25
18
|
}
|
|
26
19
|
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/*
|
|
30
|
-
* Style link form differently when manual decorators are available.
|
|
31
|
-
* See: https://github.com/ckeditor/ckeditor5-link/issues/186.
|
|
32
|
-
*/
|
|
33
|
-
.ck.ck-link-form_layout-vertical {
|
|
34
|
-
display: block;
|
|
35
20
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* keep the top margin of action buttons medium.
|
|
39
|
-
*/
|
|
40
|
-
& .ck-button {
|
|
41
|
-
&.ck-button-save,
|
|
42
|
-
&.ck-button-cancel {
|
|
43
|
-
margin-top: var(--ck-spacing-medium);
|
|
44
|
-
}
|
|
21
|
+
& .ck-link__items:empty {
|
|
22
|
+
display: none;
|
|
45
23
|
}
|
|
46
24
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2025, 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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2025, 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
|
+
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, 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
|
-
* @module link/ui/linkactionsview
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView, View } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { FocusTracker, KeystrokeHandler, type LocaleTranslate, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
11
|
-
import '../../theme/linkactions.css';
|
|
12
|
-
import type { LinkConfig } from '../linkconfig.js';
|
|
13
|
-
/**
|
|
14
|
-
* The link actions view class. This view displays the link preview, allows
|
|
15
|
-
* unlinking or editing the link.
|
|
16
|
-
*/
|
|
17
|
-
export default class LinkActionsView extends View {
|
|
18
|
-
/**
|
|
19
|
-
* Tracks information about DOM focus in the actions.
|
|
20
|
-
*/
|
|
21
|
-
readonly focusTracker: FocusTracker;
|
|
22
|
-
/**
|
|
23
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
24
|
-
*/
|
|
25
|
-
readonly keystrokes: KeystrokeHandler;
|
|
26
|
-
/**
|
|
27
|
-
* The href preview view.
|
|
28
|
-
*/
|
|
29
|
-
previewButtonView: ButtonView;
|
|
30
|
-
/**
|
|
31
|
-
* The unlink button view.
|
|
32
|
-
*/
|
|
33
|
-
unlinkButtonView: ButtonView;
|
|
34
|
-
/**
|
|
35
|
-
* The edit link button view.
|
|
36
|
-
*/
|
|
37
|
-
editButtonView: ButtonView;
|
|
38
|
-
/**
|
|
39
|
-
* The value of the "href" attribute of the link to use in the {@link #previewButtonView}.
|
|
40
|
-
*
|
|
41
|
-
* @observable
|
|
42
|
-
*/
|
|
43
|
-
href: string | undefined;
|
|
44
|
-
/**
|
|
45
|
-
* A collection of views that can be focused in the view.
|
|
46
|
-
*/
|
|
47
|
-
private readonly _focusables;
|
|
48
|
-
/**
|
|
49
|
-
* Helps cycling over {@link #_focusables} in the view.
|
|
50
|
-
*/
|
|
51
|
-
private readonly _focusCycler;
|
|
52
|
-
private readonly _linkConfig;
|
|
53
|
-
private readonly _options?;
|
|
54
|
-
t: LocaleTranslate;
|
|
55
|
-
/**
|
|
56
|
-
* @inheritDoc
|
|
57
|
-
*/
|
|
58
|
-
constructor(locale: Locale, linkConfig?: LinkConfig, options?: LinkActionsViewOptions);
|
|
59
|
-
/**
|
|
60
|
-
* @inheritDoc
|
|
61
|
-
*/
|
|
62
|
-
render(): void;
|
|
63
|
-
/**
|
|
64
|
-
* @inheritDoc
|
|
65
|
-
*/
|
|
66
|
-
destroy(): void;
|
|
67
|
-
/**
|
|
68
|
-
* Focuses the fist {@link #_focusables} in the actions.
|
|
69
|
-
*/
|
|
70
|
-
focus(): void;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a button view.
|
|
73
|
-
*
|
|
74
|
-
* @param label The button label.
|
|
75
|
-
* @param icon The button icon.
|
|
76
|
-
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
77
|
-
* @returns The button view instance.
|
|
78
|
-
*/
|
|
79
|
-
private _createButton;
|
|
80
|
-
/**
|
|
81
|
-
* Creates a link href preview button.
|
|
82
|
-
*
|
|
83
|
-
* @returns The button view instance.
|
|
84
|
-
*/
|
|
85
|
-
private _createPreviewButton;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Fired when the {@link ~LinkActionsView#editButtonView} is clicked.
|
|
89
|
-
*
|
|
90
|
-
* @eventName ~LinkActionsView#edit
|
|
91
|
-
*/
|
|
92
|
-
export type EditEvent = {
|
|
93
|
-
name: 'edit';
|
|
94
|
-
args: [];
|
|
95
|
-
};
|
|
96
|
-
/**
|
|
97
|
-
* Fired when the {@link ~LinkActionsView#unlinkButtonView} is clicked.
|
|
98
|
-
*
|
|
99
|
-
* @eventName ~LinkActionsView#unlink
|
|
100
|
-
*/
|
|
101
|
-
export type UnlinkEvent = {
|
|
102
|
-
name: 'unlink';
|
|
103
|
-
args: [];
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* The options that are passed to the {@link ~LinkActionsView#constructor} constructor.
|
|
107
|
-
*/
|
|
108
|
-
export type LinkActionsViewOptions = {
|
|
109
|
-
/**
|
|
110
|
-
* Returns `true` when bookmark `id` matches the hash from `link`.
|
|
111
|
-
*/
|
|
112
|
-
isScrollableToTarget: (href: string | undefined) => boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Scrolls the view to the desired bookmark or open a link in new window.
|
|
115
|
-
*/
|
|
116
|
-
scrollToTarget: (href: string) => void;
|
|
117
|
-
};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2025, 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
|
-
* @module link/ui/linkactionsview
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView, View, ViewCollection, FocusCycler } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import { icons } from 'ckeditor5/src/core.js';
|
|
11
|
-
import { ensureSafeUrl, openLink } from '../utils.js';
|
|
12
|
-
// See: #8833.
|
|
13
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
14
|
-
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
15
|
-
import '../../theme/linkactions.css';
|
|
16
|
-
import unlinkIcon from '../../theme/icons/unlink.svg';
|
|
17
|
-
/**
|
|
18
|
-
* The link actions view class. This view displays the link preview, allows
|
|
19
|
-
* unlinking or editing the link.
|
|
20
|
-
*/
|
|
21
|
-
export default class LinkActionsView extends View {
|
|
22
|
-
/**
|
|
23
|
-
* @inheritDoc
|
|
24
|
-
*/
|
|
25
|
-
constructor(locale, linkConfig = {}, options) {
|
|
26
|
-
super(locale);
|
|
27
|
-
/**
|
|
28
|
-
* Tracks information about DOM focus in the actions.
|
|
29
|
-
*/
|
|
30
|
-
this.focusTracker = new FocusTracker();
|
|
31
|
-
/**
|
|
32
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
33
|
-
*/
|
|
34
|
-
this.keystrokes = new KeystrokeHandler();
|
|
35
|
-
/**
|
|
36
|
-
* A collection of views that can be focused in the view.
|
|
37
|
-
*/
|
|
38
|
-
this._focusables = new ViewCollection();
|
|
39
|
-
const t = locale.t;
|
|
40
|
-
this._options = options;
|
|
41
|
-
this.previewButtonView = this._createPreviewButton();
|
|
42
|
-
this.unlinkButtonView = this._createButton(t('Unlink'), unlinkIcon, 'unlink');
|
|
43
|
-
this.editButtonView = this._createButton(t('Edit link'), icons.pencil, 'edit');
|
|
44
|
-
this.set('href', undefined);
|
|
45
|
-
this._linkConfig = linkConfig;
|
|
46
|
-
this._focusCycler = new FocusCycler({
|
|
47
|
-
focusables: this._focusables,
|
|
48
|
-
focusTracker: this.focusTracker,
|
|
49
|
-
keystrokeHandler: this.keystrokes,
|
|
50
|
-
actions: {
|
|
51
|
-
// Navigate fields backwards using the Shift + Tab keystroke.
|
|
52
|
-
focusPrevious: 'shift + tab',
|
|
53
|
-
// Navigate fields forwards using the Tab key.
|
|
54
|
-
focusNext: 'tab'
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
this.setTemplate({
|
|
58
|
-
tag: 'div',
|
|
59
|
-
attributes: {
|
|
60
|
-
class: [
|
|
61
|
-
'ck',
|
|
62
|
-
'ck-link-actions',
|
|
63
|
-
'ck-responsive-form'
|
|
64
|
-
],
|
|
65
|
-
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
66
|
-
tabindex: '-1'
|
|
67
|
-
},
|
|
68
|
-
children: [
|
|
69
|
-
this.previewButtonView,
|
|
70
|
-
this.editButtonView,
|
|
71
|
-
this.unlinkButtonView
|
|
72
|
-
]
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* @inheritDoc
|
|
77
|
-
*/
|
|
78
|
-
render() {
|
|
79
|
-
super.render();
|
|
80
|
-
const childViews = [
|
|
81
|
-
this.previewButtonView,
|
|
82
|
-
this.editButtonView,
|
|
83
|
-
this.unlinkButtonView
|
|
84
|
-
];
|
|
85
|
-
childViews.forEach(v => {
|
|
86
|
-
// Register the view as focusable.
|
|
87
|
-
this._focusables.add(v);
|
|
88
|
-
// Register the view in the focus tracker.
|
|
89
|
-
this.focusTracker.add(v.element);
|
|
90
|
-
});
|
|
91
|
-
// Start listening for the keystrokes coming from #element.
|
|
92
|
-
this.keystrokes.listenTo(this.element);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @inheritDoc
|
|
96
|
-
*/
|
|
97
|
-
destroy() {
|
|
98
|
-
super.destroy();
|
|
99
|
-
this.focusTracker.destroy();
|
|
100
|
-
this.keystrokes.destroy();
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Focuses the fist {@link #_focusables} in the actions.
|
|
104
|
-
*/
|
|
105
|
-
focus() {
|
|
106
|
-
this._focusCycler.focusFirst();
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Creates a button view.
|
|
110
|
-
*
|
|
111
|
-
* @param label The button label.
|
|
112
|
-
* @param icon The button icon.
|
|
113
|
-
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
114
|
-
* @returns The button view instance.
|
|
115
|
-
*/
|
|
116
|
-
_createButton(label, icon, eventName) {
|
|
117
|
-
const button = new ButtonView(this.locale);
|
|
118
|
-
button.set({
|
|
119
|
-
label,
|
|
120
|
-
icon,
|
|
121
|
-
tooltip: true
|
|
122
|
-
});
|
|
123
|
-
button.delegate('execute').to(this, eventName);
|
|
124
|
-
return button;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Creates a link href preview button.
|
|
128
|
-
*
|
|
129
|
-
* @returns The button view instance.
|
|
130
|
-
*/
|
|
131
|
-
_createPreviewButton() {
|
|
132
|
-
const button = new ButtonView(this.locale);
|
|
133
|
-
const bind = this.bindTemplate;
|
|
134
|
-
const t = this.t;
|
|
135
|
-
button.set({
|
|
136
|
-
withText: true
|
|
137
|
-
});
|
|
138
|
-
button.extendTemplate({
|
|
139
|
-
attributes: {
|
|
140
|
-
class: [
|
|
141
|
-
'ck',
|
|
142
|
-
'ck-link-actions__preview'
|
|
143
|
-
],
|
|
144
|
-
href: bind.to('href', href => href && ensureSafeUrl(href, this._linkConfig.allowedProtocols)),
|
|
145
|
-
target: '_blank',
|
|
146
|
-
rel: 'noopener noreferrer'
|
|
147
|
-
},
|
|
148
|
-
on: {
|
|
149
|
-
click: bind.to(evt => {
|
|
150
|
-
if (this._options && this._options.isScrollableToTarget(this.href)) {
|
|
151
|
-
evt.preventDefault();
|
|
152
|
-
this._options.scrollToTarget(this.href);
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
openLink(this.href);
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
button.bind('tooltip').to(this, 'href', href => {
|
|
161
|
-
if (this._options && this._options.isScrollableToTarget(href)) {
|
|
162
|
-
return t('Scroll to target');
|
|
163
|
-
}
|
|
164
|
-
return t('Open link in new tab');
|
|
165
|
-
});
|
|
166
|
-
button.bind('label').to(this, 'href', href => {
|
|
167
|
-
return href || t('This link has no URL');
|
|
168
|
-
});
|
|
169
|
-
button.bind('isEnabled').to(this, 'href', href => !!href);
|
|
170
|
-
button.template.tag = 'a';
|
|
171
|
-
return button;
|
|
172
|
-
}
|
|
173
|
-
}
|
package/theme/icons/link.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184z"/></svg>
|
package/theme/icons/unlink.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="m11.077 15 .991-1.416a.75.75 0 1 1 1.229.86l-1.148 1.64a.748.748 0 0 1-.217.206 5.251 5.251 0 0 1-8.503-5.955.741.741 0 0 1 .12-.274l1.147-1.639a.75.75 0 1 1 1.228.86L4.933 10.7l.006.003a3.75 3.75 0 0 0 6.132 4.294l.006.004zm5.494-5.335a.748.748 0 0 1-.12.274l-1.147 1.639a.75.75 0 1 1-1.228-.86l.86-1.23a3.75 3.75 0 0 0-6.144-4.301l-.86 1.229a.75.75 0 0 1-1.229-.86l1.148-1.64a.748.748 0 0 1 .217-.206 5.251 5.251 0 0 1 8.503 5.955zm-4.563-2.532a.75.75 0 0 1 .184 1.045l-3.155 4.505a.75.75 0 1 1-1.229-.86l3.155-4.506a.75.75 0 0 1 1.045-.184zm4.919 10.562-1.414 1.414a.75.75 0 1 1-1.06-1.06l1.414-1.415-1.415-1.414a.75.75 0 0 1 1.061-1.06l1.414 1.414 1.414-1.415a.75.75 0 0 1 1.061 1.061l-1.414 1.414 1.414 1.415a.75.75 0 0 1-1.06 1.06l-1.415-1.414z"/></svg>
|
package/theme/linkactions.css
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2025, 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
|
-
.ck.ck-link-actions {
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: row;
|
|
11
|
-
flex-wrap: nowrap;
|
|
12
|
-
|
|
13
|
-
& .ck-link-actions__preview {
|
|
14
|
-
display: inline-block;
|
|
15
|
-
|
|
16
|
-
& .ck-button__label {
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@mixin ck-media-phone {
|
|
22
|
-
flex-wrap: wrap;
|
|
23
|
-
|
|
24
|
-
& .ck-link-actions__preview {
|
|
25
|
-
flex-basis: 100%;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
& .ck-button:not(.ck-link-actions__preview) {
|
|
29
|
-
flex-basis: 50%;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|