@ckeditor/ckeditor5-link 44.3.0 → 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
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { ButtonView, IconView } from 'ckeditor5/src/ui.js';
|
|
6
|
+
import type { Locale } from 'ckeditor5/src/utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Represents a view for a dropdown menu button.
|
|
9
|
+
*/
|
|
10
|
+
export default class LinkButtonView extends ButtonView {
|
|
11
|
+
/**
|
|
12
|
+
* An icon that displays an arrow to indicate a direction of the menu.
|
|
13
|
+
*/
|
|
14
|
+
readonly arrowView: IconView;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of the dropdown menu button view.
|
|
17
|
+
*
|
|
18
|
+
* @param locale The localization services instance.
|
|
19
|
+
*/
|
|
20
|
+
constructor(locale?: Locale);
|
|
21
|
+
/**
|
|
22
|
+
* @inheritDoc
|
|
23
|
+
*/
|
|
24
|
+
render(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Creates the arrow view instance.
|
|
27
|
+
*
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
private _createArrowView;
|
|
31
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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/linkbuttonview
|
|
7
|
+
*/
|
|
8
|
+
import { IconNextArrow } from '@ckeditor/ckeditor5-icons';
|
|
9
|
+
import { ButtonView, IconView } from 'ckeditor5/src/ui.js';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a view for a dropdown menu button.
|
|
12
|
+
*/
|
|
13
|
+
export default class LinkButtonView extends ButtonView {
|
|
14
|
+
/**
|
|
15
|
+
* An icon that displays an arrow to indicate a direction of the menu.
|
|
16
|
+
*/
|
|
17
|
+
arrowView;
|
|
18
|
+
/**
|
|
19
|
+
* Creates an instance of the dropdown menu button view.
|
|
20
|
+
*
|
|
21
|
+
* @param locale The localization services instance.
|
|
22
|
+
*/
|
|
23
|
+
constructor(locale) {
|
|
24
|
+
super(locale);
|
|
25
|
+
this.set({
|
|
26
|
+
withText: true
|
|
27
|
+
});
|
|
28
|
+
this.arrowView = this._createArrowView();
|
|
29
|
+
this.extendTemplate({
|
|
30
|
+
attributes: {
|
|
31
|
+
class: [
|
|
32
|
+
'ck-link__button'
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @inheritDoc
|
|
39
|
+
*/
|
|
40
|
+
render() {
|
|
41
|
+
super.render();
|
|
42
|
+
this.children.add(this.arrowView);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates the arrow view instance.
|
|
46
|
+
*
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
_createArrowView() {
|
|
50
|
+
const arrowView = new IconView();
|
|
51
|
+
arrowView.content = IconNextArrow;
|
|
52
|
+
return arrowView;
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/ui/linkformview.d.ts
CHANGED
|
@@ -7,13 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { ButtonView, LabeledFieldView, View, ViewCollection, type InputTextView } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import type LinkCommand from '../linkcommand.js';
|
|
11
10
|
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
11
|
+
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
12
12
|
import '../../theme/linkform.css';
|
|
13
13
|
/**
|
|
14
|
-
* The link form view
|
|
15
|
-
*
|
|
16
|
-
* See {@link module:link/ui/linkformview~LinkFormView}.
|
|
14
|
+
* The link form view.
|
|
17
15
|
*/
|
|
18
16
|
export default class LinkFormView extends View {
|
|
19
17
|
/**
|
|
@@ -25,27 +23,29 @@ export default class LinkFormView extends View {
|
|
|
25
23
|
*/
|
|
26
24
|
readonly keystrokes: KeystrokeHandler;
|
|
27
25
|
/**
|
|
28
|
-
* The
|
|
26
|
+
* The Back button view displayed in the header.
|
|
29
27
|
*/
|
|
30
|
-
|
|
28
|
+
backButtonView: ButtonView;
|
|
31
29
|
/**
|
|
32
30
|
* The Save button view.
|
|
33
31
|
*/
|
|
34
32
|
saveButtonView: ButtonView;
|
|
35
33
|
/**
|
|
36
|
-
* The
|
|
34
|
+
* The "Displayed text" input view.
|
|
37
35
|
*/
|
|
38
|
-
|
|
36
|
+
displayedTextInputView: LabeledFieldView<InputTextView>;
|
|
39
37
|
/**
|
|
40
|
-
*
|
|
41
|
-
* which corresponds to {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators}
|
|
42
|
-
* configured in the editor.
|
|
38
|
+
* The URL input view.
|
|
43
39
|
*/
|
|
44
|
-
|
|
40
|
+
urlInputView: LabeledFieldView<InputTextView>;
|
|
45
41
|
/**
|
|
46
|
-
* A collection of child views
|
|
42
|
+
* A collection of child views.
|
|
47
43
|
*/
|
|
48
44
|
readonly children: ViewCollection;
|
|
45
|
+
/**
|
|
46
|
+
* A collection of child views in the providers list.
|
|
47
|
+
*/
|
|
48
|
+
readonly providersListChildren: ViewCollection<ButtonView>;
|
|
49
49
|
/**
|
|
50
50
|
* An array of form validators used by {@link #isValid}.
|
|
51
51
|
*/
|
|
@@ -64,18 +64,9 @@ export default class LinkFormView extends View {
|
|
|
64
64
|
* Also see {@link #render}.
|
|
65
65
|
*
|
|
66
66
|
* @param locale The localization services instance.
|
|
67
|
-
* @param linkCommand Reference to {@link module:link/linkcommand~LinkCommand}.
|
|
68
67
|
* @param validators Form validators used by {@link #isValid}.
|
|
69
68
|
*/
|
|
70
|
-
constructor(locale: Locale,
|
|
71
|
-
/**
|
|
72
|
-
* Obtains the state of the {@link module:ui/button/switchbuttonview~SwitchButtonView switch buttons} representing
|
|
73
|
-
* {@link module:link/linkcommand~LinkCommand#manualDecorators manual link decorators}
|
|
74
|
-
* in the {@link module:link/ui/linkformview~LinkFormView}.
|
|
75
|
-
*
|
|
76
|
-
* @returns Key-value pairs, where the key is the name of the decorator and the value is its state.
|
|
77
|
-
*/
|
|
78
|
-
getDecoratorSwitchesState(): Record<string, boolean>;
|
|
69
|
+
constructor(locale: Locale, validators: Array<LinkFormValidatorCallback>);
|
|
79
70
|
/**
|
|
80
71
|
* @inheritDoc
|
|
81
72
|
*/
|
|
@@ -100,39 +91,33 @@ export default class LinkFormView extends View {
|
|
|
100
91
|
*/
|
|
101
92
|
resetFormStatus(): void;
|
|
102
93
|
/**
|
|
103
|
-
* Creates a
|
|
104
|
-
*
|
|
105
|
-
* @returns Labeled field view instance.
|
|
94
|
+
* Creates a back button view that cancels the form.
|
|
106
95
|
*/
|
|
107
|
-
private
|
|
96
|
+
private _createBackButton;
|
|
108
97
|
/**
|
|
109
|
-
* Creates a button view.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
|
|
115
|
-
|
|
98
|
+
* Creates a save button view that inserts the link.
|
|
99
|
+
*/
|
|
100
|
+
private _createSaveButton;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a header view for the form.
|
|
103
|
+
*/
|
|
104
|
+
private _createHeaderView;
|
|
105
|
+
/**
|
|
106
|
+
* Creates a view for the providers list.
|
|
116
107
|
*/
|
|
117
|
-
private
|
|
108
|
+
private _createProvidersListView;
|
|
118
109
|
/**
|
|
119
|
-
*
|
|
120
|
-
|
|
110
|
+
* Creates a labeled input view for the "Displayed text" field.
|
|
111
|
+
*/
|
|
112
|
+
private _createDisplayedTextInput;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a labeled input view for the URL field.
|
|
121
115
|
*
|
|
122
|
-
* @
|
|
123
|
-
* @returns ViewCollection of switch buttons.
|
|
116
|
+
* @returns Labeled field view instance.
|
|
124
117
|
*/
|
|
125
|
-
private
|
|
118
|
+
private _createUrlInput;
|
|
126
119
|
/**
|
|
127
120
|
* Populates the {@link #children} collection of the form.
|
|
128
|
-
*
|
|
129
|
-
* If {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators} are configured in the editor, it creates an
|
|
130
|
-
* additional `View` wrapping all {@link #_manualDecoratorSwitches} switch buttons corresponding
|
|
131
|
-
* to these decorators.
|
|
132
|
-
*
|
|
133
|
-
* @param manualDecorators A reference to
|
|
134
|
-
* the collection of manual decorators stored in the link command.
|
|
135
|
-
* @returns The children of link form view.
|
|
136
121
|
*/
|
|
137
122
|
private _createFormChildren;
|
|
138
123
|
/**
|
|
@@ -161,7 +146,7 @@ export type SubmitEvent = {
|
|
|
161
146
|
args: [];
|
|
162
147
|
};
|
|
163
148
|
/**
|
|
164
|
-
* Fired when the form view is canceled, for example with a click on {@link ~LinkFormView#
|
|
149
|
+
* Fired when the form view is canceled, for example with a click on {@link ~LinkFormView#backButtonView}.
|
|
165
150
|
*
|
|
166
151
|
* @eventName ~LinkFormView#cancel
|
|
167
152
|
*/
|
package/src/ui/linkformview.js
CHANGED
|
@@ -5,50 +5,91 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module link/ui/linkformview
|
|
7
7
|
*/
|
|
8
|
-
import { ButtonView, FocusCycler, LabeledFieldView,
|
|
8
|
+
import { ButtonView, ListView, ListItemView, FocusCycler, LabeledFieldView, FormHeaderView, FormRowView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import {
|
|
10
|
+
import { IconPreviousArrow } from 'ckeditor5/src/icons.js';
|
|
11
11
|
// See: #8833.
|
|
12
12
|
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
13
13
|
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
14
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
15
|
+
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
14
16
|
import '../../theme/linkform.css';
|
|
15
17
|
/**
|
|
16
|
-
* The link form view
|
|
17
|
-
*
|
|
18
|
-
* See {@link module:link/ui/linkformview~LinkFormView}.
|
|
18
|
+
* The link form view.
|
|
19
19
|
*/
|
|
20
20
|
export default class LinkFormView extends View {
|
|
21
|
+
/**
|
|
22
|
+
* Tracks information about DOM focus in the form.
|
|
23
|
+
*/
|
|
24
|
+
focusTracker = new FocusTracker();
|
|
25
|
+
/**
|
|
26
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
27
|
+
*/
|
|
28
|
+
keystrokes = new KeystrokeHandler();
|
|
29
|
+
/**
|
|
30
|
+
* The Back button view displayed in the header.
|
|
31
|
+
*/
|
|
32
|
+
backButtonView;
|
|
33
|
+
/**
|
|
34
|
+
* The Save button view.
|
|
35
|
+
*/
|
|
36
|
+
saveButtonView;
|
|
37
|
+
/**
|
|
38
|
+
* The "Displayed text" input view.
|
|
39
|
+
*/
|
|
40
|
+
displayedTextInputView;
|
|
41
|
+
/**
|
|
42
|
+
* The URL input view.
|
|
43
|
+
*/
|
|
44
|
+
urlInputView;
|
|
45
|
+
/**
|
|
46
|
+
* A collection of child views.
|
|
47
|
+
*/
|
|
48
|
+
children;
|
|
49
|
+
/**
|
|
50
|
+
* A collection of child views in the providers list.
|
|
51
|
+
*/
|
|
52
|
+
providersListChildren;
|
|
53
|
+
/**
|
|
54
|
+
* An array of form validators used by {@link #isValid}.
|
|
55
|
+
*/
|
|
56
|
+
_validators;
|
|
57
|
+
/**
|
|
58
|
+
* A collection of views that can be focused in the form.
|
|
59
|
+
*/
|
|
60
|
+
_focusables = new ViewCollection();
|
|
61
|
+
/**
|
|
62
|
+
* Helps cycling over {@link #_focusables} in the form.
|
|
63
|
+
*/
|
|
64
|
+
_focusCycler;
|
|
21
65
|
/**
|
|
22
66
|
* Creates an instance of the {@link module:link/ui/linkformview~LinkFormView} class.
|
|
23
67
|
*
|
|
24
68
|
* Also see {@link #render}.
|
|
25
69
|
*
|
|
26
70
|
* @param locale The localization services instance.
|
|
27
|
-
* @param linkCommand Reference to {@link module:link/linkcommand~LinkCommand}.
|
|
28
71
|
* @param validators Form validators used by {@link #isValid}.
|
|
29
72
|
*/
|
|
30
|
-
constructor(locale,
|
|
73
|
+
constructor(locale, validators) {
|
|
31
74
|
super(locale);
|
|
32
|
-
/**
|
|
33
|
-
* Tracks information about DOM focus in the form.
|
|
34
|
-
*/
|
|
35
|
-
this.focusTracker = new FocusTracker();
|
|
36
|
-
/**
|
|
37
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
38
|
-
*/
|
|
39
|
-
this.keystrokes = new KeystrokeHandler();
|
|
40
|
-
/**
|
|
41
|
-
* A collection of views that can be focused in the form.
|
|
42
|
-
*/
|
|
43
|
-
this._focusables = new ViewCollection();
|
|
44
|
-
const t = locale.t;
|
|
45
75
|
this._validators = validators;
|
|
76
|
+
// Create buttons.
|
|
77
|
+
this.backButtonView = this._createBackButton();
|
|
78
|
+
this.saveButtonView = this._createSaveButton();
|
|
79
|
+
// Create input fields.
|
|
80
|
+
this.displayedTextInputView = this._createDisplayedTextInput();
|
|
46
81
|
this.urlInputView = this._createUrlInput();
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
82
|
+
this.providersListChildren = this.createCollection();
|
|
83
|
+
this.children = this.createCollection([
|
|
84
|
+
this._createHeaderView()
|
|
85
|
+
]);
|
|
86
|
+
this._createFormChildren();
|
|
87
|
+
// Add providers list view to the children when the first item is added to the list.
|
|
88
|
+
// This is to avoid adding the list view when the form is empty.
|
|
89
|
+
this.listenTo(this.providersListChildren, 'add', () => {
|
|
90
|
+
this.stopListening(this.providersListChildren, 'add');
|
|
91
|
+
this.children.add(this._createProvidersListView());
|
|
92
|
+
});
|
|
52
93
|
this._focusCycler = new FocusCycler({
|
|
53
94
|
focusables: this._focusables,
|
|
54
95
|
focusTracker: this.focusTracker,
|
|
@@ -60,35 +101,21 @@ export default class LinkFormView extends View {
|
|
|
60
101
|
focusNext: 'tab'
|
|
61
102
|
}
|
|
62
103
|
});
|
|
63
|
-
const classList = ['ck', 'ck-link-form', 'ck-responsive-form'];
|
|
64
|
-
if (linkCommand.manualDecorators.length) {
|
|
65
|
-
classList.push('ck-link-form_layout-vertical', 'ck-vertical-form');
|
|
66
|
-
}
|
|
67
104
|
this.setTemplate({
|
|
68
105
|
tag: 'form',
|
|
69
106
|
attributes: {
|
|
70
|
-
class:
|
|
107
|
+
class: [
|
|
108
|
+
'ck',
|
|
109
|
+
'ck-form',
|
|
110
|
+
'ck-link-form',
|
|
111
|
+
'ck-responsive-form'
|
|
112
|
+
],
|
|
71
113
|
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
72
114
|
tabindex: '-1'
|
|
73
115
|
},
|
|
74
116
|
children: this.children
|
|
75
117
|
});
|
|
76
118
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Obtains the state of the {@link module:ui/button/switchbuttonview~SwitchButtonView switch buttons} representing
|
|
79
|
-
* {@link module:link/linkcommand~LinkCommand#manualDecorators manual link decorators}
|
|
80
|
-
* in the {@link module:link/ui/linkformview~LinkFormView}.
|
|
81
|
-
*
|
|
82
|
-
* @returns Key-value pairs, where the key is the name of the decorator and the value is its state.
|
|
83
|
-
*/
|
|
84
|
-
getDecoratorSwitchesState() {
|
|
85
|
-
return Array
|
|
86
|
-
.from(this._manualDecoratorSwitches)
|
|
87
|
-
.reduce((accumulator, switchButton) => {
|
|
88
|
-
accumulator[switchButton.name] = switchButton.isOn;
|
|
89
|
-
return accumulator;
|
|
90
|
-
}, {});
|
|
91
|
-
}
|
|
92
119
|
/**
|
|
93
120
|
* @inheritDoc
|
|
94
121
|
*/
|
|
@@ -99,9 +126,10 @@ export default class LinkFormView extends View {
|
|
|
99
126
|
});
|
|
100
127
|
const childViews = [
|
|
101
128
|
this.urlInputView,
|
|
102
|
-
...this._manualDecoratorSwitches,
|
|
103
129
|
this.saveButtonView,
|
|
104
|
-
this.
|
|
130
|
+
...this.providersListChildren,
|
|
131
|
+
this.backButtonView,
|
|
132
|
+
this.displayedTextInputView
|
|
105
133
|
];
|
|
106
134
|
childViews.forEach(v => {
|
|
107
135
|
// Register the view as focusable.
|
|
@@ -152,110 +180,111 @@ export default class LinkFormView extends View {
|
|
|
152
180
|
this.urlInputView.errorText = null;
|
|
153
181
|
}
|
|
154
182
|
/**
|
|
155
|
-
* Creates a
|
|
156
|
-
*
|
|
157
|
-
* @returns Labeled field view instance.
|
|
183
|
+
* Creates a back button view that cancels the form.
|
|
158
184
|
*/
|
|
159
|
-
|
|
185
|
+
_createBackButton() {
|
|
160
186
|
const t = this.locale.t;
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
187
|
+
const backButton = new ButtonView(this.locale);
|
|
188
|
+
backButton.set({
|
|
189
|
+
class: 'ck-button-back',
|
|
190
|
+
label: t('Back'),
|
|
191
|
+
icon: IconPreviousArrow,
|
|
192
|
+
tooltip: true
|
|
193
|
+
});
|
|
194
|
+
backButton.delegate('execute').to(this, 'cancel');
|
|
195
|
+
return backButton;
|
|
165
196
|
}
|
|
166
197
|
/**
|
|
167
|
-
* Creates a button view.
|
|
168
|
-
*
|
|
169
|
-
* @param label The button label.
|
|
170
|
-
* @param icon The button icon.
|
|
171
|
-
* @param className The additional button CSS class name.
|
|
172
|
-
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
173
|
-
* @returns The button view instance.
|
|
198
|
+
* Creates a save button view that inserts the link.
|
|
174
199
|
*/
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
tooltip:
|
|
200
|
+
_createSaveButton() {
|
|
201
|
+
const t = this.locale.t;
|
|
202
|
+
const saveButton = new ButtonView(this.locale);
|
|
203
|
+
saveButton.set({
|
|
204
|
+
label: t('Insert'),
|
|
205
|
+
tooltip: false,
|
|
206
|
+
withText: true,
|
|
207
|
+
type: 'submit',
|
|
208
|
+
class: 'ck-button-action ck-button-bold'
|
|
181
209
|
});
|
|
182
|
-
|
|
210
|
+
return saveButton;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Creates a header view for the form.
|
|
214
|
+
*/
|
|
215
|
+
_createHeaderView() {
|
|
216
|
+
const t = this.locale.t;
|
|
217
|
+
const header = new FormHeaderView(this.locale, {
|
|
218
|
+
label: t('Link')
|
|
219
|
+
});
|
|
220
|
+
header.children.add(this.backButtonView, 0);
|
|
221
|
+
return header;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Creates a view for the providers list.
|
|
225
|
+
*/
|
|
226
|
+
_createProvidersListView() {
|
|
227
|
+
const providersListView = new ListView(this.locale);
|
|
228
|
+
providersListView.extendTemplate({
|
|
183
229
|
attributes: {
|
|
184
|
-
class:
|
|
230
|
+
class: [
|
|
231
|
+
'ck-link-form__providers-list'
|
|
232
|
+
]
|
|
185
233
|
}
|
|
186
234
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
235
|
+
providersListView.items.bindTo(this.providersListChildren).using(def => {
|
|
236
|
+
const listItemView = new ListItemView(this.locale);
|
|
237
|
+
listItemView.children.add(def);
|
|
238
|
+
return listItemView;
|
|
239
|
+
});
|
|
240
|
+
return providersListView;
|
|
191
241
|
}
|
|
192
242
|
/**
|
|
193
|
-
*
|
|
194
|
-
|
|
243
|
+
* Creates a labeled input view for the "Displayed text" field.
|
|
244
|
+
*/
|
|
245
|
+
_createDisplayedTextInput() {
|
|
246
|
+
const t = this.locale.t;
|
|
247
|
+
const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
|
|
248
|
+
labeledInput.label = t('Displayed text');
|
|
249
|
+
labeledInput.class = 'ck-labeled-field-view_full-width';
|
|
250
|
+
return labeledInput;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Creates a labeled input view for the URL field.
|
|
195
254
|
*
|
|
196
|
-
* @
|
|
197
|
-
* @returns ViewCollection of switch buttons.
|
|
255
|
+
* @returns Labeled field view instance.
|
|
198
256
|
*/
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
withText: true
|
|
207
|
-
});
|
|
208
|
-
switchButton.bind('isOn').toMany([manualDecorator, linkCommand], 'value', (decoratorValue, commandValue) => {
|
|
209
|
-
return commandValue === undefined && decoratorValue === undefined ? !!manualDecorator.defaultValue : !!decoratorValue;
|
|
210
|
-
});
|
|
211
|
-
switchButton.on('execute', () => {
|
|
212
|
-
manualDecorator.set('value', !switchButton.isOn);
|
|
213
|
-
});
|
|
214
|
-
switches.add(switchButton);
|
|
215
|
-
}
|
|
216
|
-
return switches;
|
|
257
|
+
_createUrlInput() {
|
|
258
|
+
const t = this.locale.t;
|
|
259
|
+
const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
|
|
260
|
+
labeledInput.fieldView.inputMode = 'url';
|
|
261
|
+
labeledInput.label = t('Link URL');
|
|
262
|
+
labeledInput.class = 'ck-labeled-field-view_full-width';
|
|
263
|
+
return labeledInput;
|
|
217
264
|
}
|
|
218
265
|
/**
|
|
219
266
|
* Populates the {@link #children} collection of the form.
|
|
220
|
-
*
|
|
221
|
-
* If {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators} are configured in the editor, it creates an
|
|
222
|
-
* additional `View` wrapping all {@link #_manualDecoratorSwitches} switch buttons corresponding
|
|
223
|
-
* to these decorators.
|
|
224
|
-
*
|
|
225
|
-
* @param manualDecorators A reference to
|
|
226
|
-
* the collection of manual decorators stored in the link command.
|
|
227
|
-
* @returns The children of link form view.
|
|
228
267
|
*/
|
|
229
|
-
_createFormChildren(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
'ck-reset',
|
|
250
|
-
'ck-list'
|
|
251
|
-
]
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
children.add(additionalButtonsView);
|
|
255
|
-
}
|
|
256
|
-
children.add(this.saveButtonView);
|
|
257
|
-
children.add(this.cancelButtonView);
|
|
258
|
-
return children;
|
|
268
|
+
_createFormChildren() {
|
|
269
|
+
this.children.add(new FormRowView(this.locale, {
|
|
270
|
+
children: [
|
|
271
|
+
this.displayedTextInputView
|
|
272
|
+
],
|
|
273
|
+
class: [
|
|
274
|
+
'ck-form__row_large-top-padding'
|
|
275
|
+
]
|
|
276
|
+
}));
|
|
277
|
+
this.children.add(new FormRowView(this.locale, {
|
|
278
|
+
children: [
|
|
279
|
+
this.urlInputView,
|
|
280
|
+
this.saveButtonView
|
|
281
|
+
],
|
|
282
|
+
class: [
|
|
283
|
+
'ck-form__row_with-submit',
|
|
284
|
+
'ck-form__row_large-top-padding',
|
|
285
|
+
'ck-form__row_large-bottom-padding'
|
|
286
|
+
]
|
|
287
|
+
}));
|
|
259
288
|
}
|
|
260
289
|
/**
|
|
261
290
|
* The native DOM `value` of the {@link #urlInputView} element.
|
|
@@ -0,0 +1,35 @@
|
|
|
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/linkpreviewbuttonview
|
|
7
|
+
*/
|
|
8
|
+
import { ButtonView } from 'ckeditor5/src/ui.js';
|
|
9
|
+
import type { Locale } from 'ckeditor5/src/utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* The link button class. Rendered as an `<a>` tag with link opening in a new tab.
|
|
12
|
+
*
|
|
13
|
+
* Provides a custom `navigate` cancelable event.
|
|
14
|
+
*/
|
|
15
|
+
export default class LinkPreviewButtonView extends ButtonView {
|
|
16
|
+
/**
|
|
17
|
+
* The value of the "href" attribute of the link.
|
|
18
|
+
*
|
|
19
|
+
* @observable
|
|
20
|
+
*/
|
|
21
|
+
href: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* @inheritDoc
|
|
24
|
+
*/
|
|
25
|
+
constructor(locale: Locale);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Fired when the button view is clicked.
|
|
29
|
+
*
|
|
30
|
+
* @eventName ~LinkPreviewButtonView#navigate
|
|
31
|
+
*/
|
|
32
|
+
export type LinkPreviewButtonNavigateEvent = {
|
|
33
|
+
name: 'navigate';
|
|
34
|
+
args: [href: string, cancel: () => void];
|
|
35
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
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/linkpreviewbuttonview
|
|
7
|
+
*/
|
|
8
|
+
import { ButtonView } from 'ckeditor5/src/ui.js';
|
|
9
|
+
/**
|
|
10
|
+
* The link button class. Rendered as an `<a>` tag with link opening in a new tab.
|
|
11
|
+
*
|
|
12
|
+
* Provides a custom `navigate` cancelable event.
|
|
13
|
+
*/
|
|
14
|
+
export default class LinkPreviewButtonView extends ButtonView {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
constructor(locale) {
|
|
19
|
+
super(locale);
|
|
20
|
+
const bind = this.bindTemplate;
|
|
21
|
+
this.set({
|
|
22
|
+
href: undefined,
|
|
23
|
+
withText: true
|
|
24
|
+
});
|
|
25
|
+
this.extendTemplate({
|
|
26
|
+
attributes: {
|
|
27
|
+
class: ['ck-link-toolbar__preview'],
|
|
28
|
+
href: bind.to('href'),
|
|
29
|
+
target: '_blank',
|
|
30
|
+
rel: 'noopener noreferrer'
|
|
31
|
+
},
|
|
32
|
+
on: {
|
|
33
|
+
click: bind.to(evt => {
|
|
34
|
+
if (this.href) {
|
|
35
|
+
const cancel = () => evt.preventDefault();
|
|
36
|
+
this.fire('navigate', this.href, cancel);
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.template.tag = 'a';
|
|
42
|
+
}
|
|
43
|
+
}
|