@ckeditor/ckeditor5-link 40.0.0 → 40.2.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/CHANGELOG.md +29 -29
- package/LICENSE.md +3 -3
- package/build/link.js +1 -1
- package/build/translations/ug.js +1 -1
- package/lang/translations/ug.po +6 -6
- package/package.json +3 -3
- package/src/augmentation.d.ts +30 -30
- package/src/augmentation.js +5 -5
- package/src/autolink.d.ts +75 -60
- package/src/autolink.js +284 -216
- package/src/index.d.ts +18 -18
- package/src/index.js +17 -17
- package/src/link.d.ts +27 -27
- package/src/link.js +31 -31
- package/src/linkcommand.d.ts +132 -132
- package/src/linkcommand.js +285 -285
- package/src/linkconfig.d.ts +251 -251
- package/src/linkconfig.js +5 -5
- package/src/linkediting.d.ts +70 -106
- package/src/linkediting.js +278 -547
- package/src/linkimage.d.ts +27 -27
- package/src/linkimage.js +31 -31
- package/src/linkimageediting.d.ts +39 -39
- package/src/linkimageediting.js +245 -245
- package/src/linkimageui.d.ts +40 -40
- package/src/linkimageui.js +96 -96
- package/src/linkui.d.ts +165 -165
- package/src/linkui.js +581 -581
- package/src/ui/linkactionsview.d.ts +101 -101
- package/src/ui/linkactionsview.js +156 -156
- package/src/ui/linkformview.d.ts +141 -141
- package/src/ui/linkformview.js +232 -232
- package/src/unlinkcommand.d.ts +31 -31
- package/src/unlinkcommand.js +66 -66
- package/src/utils/automaticdecorators.d.ts +45 -45
- package/src/utils/automaticdecorators.js +140 -140
- package/src/utils/manualdecorator.d.ts +72 -72
- package/src/utils/manualdecorator.js +47 -47
- package/src/utils.d.ts +80 -80
- package/src/utils.js +128 -128
- package/build/link.js.map +0 -1
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module link/ui/linkactionsview
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView, View } from 'ckeditor5/src/ui';
|
|
9
|
-
import { FocusTracker, KeystrokeHandler, type LocaleTranslate, type Locale } from 'ckeditor5/src/utils';
|
|
10
|
-
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
11
|
-
import '../../theme/linkactions.css';
|
|
12
|
-
/**
|
|
13
|
-
* The link actions view class. This view displays the link preview, allows
|
|
14
|
-
* unlinking or editing the link.
|
|
15
|
-
*/
|
|
16
|
-
export default class LinkActionsView extends View {
|
|
17
|
-
/**
|
|
18
|
-
* Tracks information about DOM focus in the actions.
|
|
19
|
-
*/
|
|
20
|
-
readonly focusTracker: FocusTracker;
|
|
21
|
-
/**
|
|
22
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
23
|
-
*/
|
|
24
|
-
readonly keystrokes: KeystrokeHandler;
|
|
25
|
-
/**
|
|
26
|
-
* The href preview view.
|
|
27
|
-
*/
|
|
28
|
-
previewButtonView: View;
|
|
29
|
-
/**
|
|
30
|
-
* The unlink button view.
|
|
31
|
-
*/
|
|
32
|
-
unlinkButtonView: ButtonView;
|
|
33
|
-
/**
|
|
34
|
-
* The edit link button view.
|
|
35
|
-
*/
|
|
36
|
-
editButtonView: ButtonView;
|
|
37
|
-
/**
|
|
38
|
-
* The value of the "href" attribute of the link to use in the {@link #previewButtonView}.
|
|
39
|
-
*
|
|
40
|
-
* @observable
|
|
41
|
-
*/
|
|
42
|
-
href: string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* A collection of views that can be focused in the view.
|
|
45
|
-
*/
|
|
46
|
-
private readonly _focusables;
|
|
47
|
-
/**
|
|
48
|
-
* Helps cycling over {@link #_focusables} in the view.
|
|
49
|
-
*/
|
|
50
|
-
private readonly _focusCycler;
|
|
51
|
-
t: LocaleTranslate;
|
|
52
|
-
/**
|
|
53
|
-
* @inheritDoc
|
|
54
|
-
*/
|
|
55
|
-
constructor(locale: Locale);
|
|
56
|
-
/**
|
|
57
|
-
* @inheritDoc
|
|
58
|
-
*/
|
|
59
|
-
render(): void;
|
|
60
|
-
/**
|
|
61
|
-
* @inheritDoc
|
|
62
|
-
*/
|
|
63
|
-
destroy(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Focuses the fist {@link #_focusables} in the actions.
|
|
66
|
-
*/
|
|
67
|
-
focus(): void;
|
|
68
|
-
/**
|
|
69
|
-
* Creates a button view.
|
|
70
|
-
*
|
|
71
|
-
* @param label The button label.
|
|
72
|
-
* @param icon The button icon.
|
|
73
|
-
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
74
|
-
* @returns The button view instance.
|
|
75
|
-
*/
|
|
76
|
-
private _createButton;
|
|
77
|
-
/**
|
|
78
|
-
* Creates a link href preview button.
|
|
79
|
-
*
|
|
80
|
-
* @returns The button view instance.
|
|
81
|
-
*/
|
|
82
|
-
private _createPreviewButton;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Fired when the {@link ~LinkActionsView#editButtonView} is clicked.
|
|
86
|
-
*
|
|
87
|
-
* @eventName ~LinkActionsView#edit
|
|
88
|
-
*/
|
|
89
|
-
export type EditEvent = {
|
|
90
|
-
name: 'edit';
|
|
91
|
-
args: [];
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Fired when the {@link ~LinkActionsView#unlinkButtonView} is clicked.
|
|
95
|
-
*
|
|
96
|
-
* @eventName ~LinkActionsView#unlink
|
|
97
|
-
*/
|
|
98
|
-
export type UnlinkEvent = {
|
|
99
|
-
name: 'unlink';
|
|
100
|
-
args: [];
|
|
101
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module link/ui/linkactionsview
|
|
7
|
+
*/
|
|
8
|
+
import { ButtonView, View } from 'ckeditor5/src/ui';
|
|
9
|
+
import { FocusTracker, KeystrokeHandler, type LocaleTranslate, type Locale } from 'ckeditor5/src/utils';
|
|
10
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
11
|
+
import '../../theme/linkactions.css';
|
|
12
|
+
/**
|
|
13
|
+
* The link actions view class. This view displays the link preview, allows
|
|
14
|
+
* unlinking or editing the link.
|
|
15
|
+
*/
|
|
16
|
+
export default class LinkActionsView extends View {
|
|
17
|
+
/**
|
|
18
|
+
* Tracks information about DOM focus in the actions.
|
|
19
|
+
*/
|
|
20
|
+
readonly focusTracker: FocusTracker;
|
|
21
|
+
/**
|
|
22
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
23
|
+
*/
|
|
24
|
+
readonly keystrokes: KeystrokeHandler;
|
|
25
|
+
/**
|
|
26
|
+
* The href preview view.
|
|
27
|
+
*/
|
|
28
|
+
previewButtonView: View;
|
|
29
|
+
/**
|
|
30
|
+
* The unlink button view.
|
|
31
|
+
*/
|
|
32
|
+
unlinkButtonView: ButtonView;
|
|
33
|
+
/**
|
|
34
|
+
* The edit link button view.
|
|
35
|
+
*/
|
|
36
|
+
editButtonView: ButtonView;
|
|
37
|
+
/**
|
|
38
|
+
* The value of the "href" attribute of the link to use in the {@link #previewButtonView}.
|
|
39
|
+
*
|
|
40
|
+
* @observable
|
|
41
|
+
*/
|
|
42
|
+
href: string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* A collection of views that can be focused in the view.
|
|
45
|
+
*/
|
|
46
|
+
private readonly _focusables;
|
|
47
|
+
/**
|
|
48
|
+
* Helps cycling over {@link #_focusables} in the view.
|
|
49
|
+
*/
|
|
50
|
+
private readonly _focusCycler;
|
|
51
|
+
t: LocaleTranslate;
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
55
|
+
constructor(locale: Locale);
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
render(): void;
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
destroy(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Focuses the fist {@link #_focusables} in the actions.
|
|
66
|
+
*/
|
|
67
|
+
focus(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a button view.
|
|
70
|
+
*
|
|
71
|
+
* @param label The button label.
|
|
72
|
+
* @param icon The button icon.
|
|
73
|
+
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
74
|
+
* @returns The button view instance.
|
|
75
|
+
*/
|
|
76
|
+
private _createButton;
|
|
77
|
+
/**
|
|
78
|
+
* Creates a link href preview button.
|
|
79
|
+
*
|
|
80
|
+
* @returns The button view instance.
|
|
81
|
+
*/
|
|
82
|
+
private _createPreviewButton;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Fired when the {@link ~LinkActionsView#editButtonView} is clicked.
|
|
86
|
+
*
|
|
87
|
+
* @eventName ~LinkActionsView#edit
|
|
88
|
+
*/
|
|
89
|
+
export type EditEvent = {
|
|
90
|
+
name: 'edit';
|
|
91
|
+
args: [];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Fired when the {@link ~LinkActionsView#unlinkButtonView} is clicked.
|
|
95
|
+
*
|
|
96
|
+
* @eventName ~LinkActionsView#unlink
|
|
97
|
+
*/
|
|
98
|
+
export type UnlinkEvent = {
|
|
99
|
+
name: 'unlink';
|
|
100
|
+
args: [];
|
|
101
|
+
};
|
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module link/ui/linkactionsview
|
|
7
|
-
*/
|
|
8
|
-
import { ButtonView, View, ViewCollection, FocusCycler } from 'ckeditor5/src/ui';
|
|
9
|
-
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
|
|
10
|
-
import { icons } from 'ckeditor5/src/core';
|
|
11
|
-
import { ensureSafeUrl } from '../utils';
|
|
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) {
|
|
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.previewButtonView = this._createPreviewButton();
|
|
41
|
-
this.unlinkButtonView = this._createButton(t('Unlink'), unlinkIcon, 'unlink');
|
|
42
|
-
this.editButtonView = this._createButton(t('Edit link'), icons.pencil, 'edit');
|
|
43
|
-
this.set('href', undefined);
|
|
44
|
-
this._focusCycler = new FocusCycler({
|
|
45
|
-
focusables: this._focusables,
|
|
46
|
-
focusTracker: this.focusTracker,
|
|
47
|
-
keystrokeHandler: this.keystrokes,
|
|
48
|
-
actions: {
|
|
49
|
-
// Navigate fields backwards using the Shift + Tab keystroke.
|
|
50
|
-
focusPrevious: 'shift + tab',
|
|
51
|
-
// Navigate fields forwards using the Tab key.
|
|
52
|
-
focusNext: 'tab'
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
this.setTemplate({
|
|
56
|
-
tag: 'div',
|
|
57
|
-
attributes: {
|
|
58
|
-
class: [
|
|
59
|
-
'ck',
|
|
60
|
-
'ck-link-actions',
|
|
61
|
-
'ck-responsive-form'
|
|
62
|
-
],
|
|
63
|
-
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
64
|
-
tabindex: '-1'
|
|
65
|
-
},
|
|
66
|
-
children: [
|
|
67
|
-
this.previewButtonView,
|
|
68
|
-
this.editButtonView,
|
|
69
|
-
this.unlinkButtonView
|
|
70
|
-
]
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* @inheritDoc
|
|
75
|
-
*/
|
|
76
|
-
render() {
|
|
77
|
-
super.render();
|
|
78
|
-
const childViews = [
|
|
79
|
-
this.previewButtonView,
|
|
80
|
-
this.editButtonView,
|
|
81
|
-
this.unlinkButtonView
|
|
82
|
-
];
|
|
83
|
-
childViews.forEach(v => {
|
|
84
|
-
// Register the view as focusable.
|
|
85
|
-
this._focusables.add(v);
|
|
86
|
-
// Register the view in the focus tracker.
|
|
87
|
-
this.focusTracker.add(v.element);
|
|
88
|
-
});
|
|
89
|
-
// Start listening for the keystrokes coming from #element.
|
|
90
|
-
this.keystrokes.listenTo(this.element);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* @inheritDoc
|
|
94
|
-
*/
|
|
95
|
-
destroy() {
|
|
96
|
-
super.destroy();
|
|
97
|
-
this.focusTracker.destroy();
|
|
98
|
-
this.keystrokes.destroy();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Focuses the fist {@link #_focusables} in the actions.
|
|
102
|
-
*/
|
|
103
|
-
focus() {
|
|
104
|
-
this._focusCycler.focusFirst();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Creates a button view.
|
|
108
|
-
*
|
|
109
|
-
* @param label The button label.
|
|
110
|
-
* @param icon The button icon.
|
|
111
|
-
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
112
|
-
* @returns The button view instance.
|
|
113
|
-
*/
|
|
114
|
-
_createButton(label, icon, eventName) {
|
|
115
|
-
const button = new ButtonView(this.locale);
|
|
116
|
-
button.set({
|
|
117
|
-
label,
|
|
118
|
-
icon,
|
|
119
|
-
tooltip: true
|
|
120
|
-
});
|
|
121
|
-
button.delegate('execute').to(this, eventName);
|
|
122
|
-
return button;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Creates a link href preview button.
|
|
126
|
-
*
|
|
127
|
-
* @returns The button view instance.
|
|
128
|
-
*/
|
|
129
|
-
_createPreviewButton() {
|
|
130
|
-
const button = new ButtonView(this.locale);
|
|
131
|
-
const bind = this.bindTemplate;
|
|
132
|
-
const t = this.t;
|
|
133
|
-
button.set({
|
|
134
|
-
withText: true,
|
|
135
|
-
tooltip: t('Open link in new tab')
|
|
136
|
-
});
|
|
137
|
-
button.extendTemplate({
|
|
138
|
-
attributes: {
|
|
139
|
-
class: [
|
|
140
|
-
'ck',
|
|
141
|
-
'ck-link-actions__preview'
|
|
142
|
-
],
|
|
143
|
-
href: bind.to('href', href => href && ensureSafeUrl(href)),
|
|
144
|
-
target: '_blank',
|
|
145
|
-
rel: 'noopener noreferrer'
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
button.bind('label').to(this, 'href', href => {
|
|
149
|
-
return href || t('This link has no URL');
|
|
150
|
-
});
|
|
151
|
-
button.bind('isEnabled').to(this, 'href', href => !!href);
|
|
152
|
-
button.template.tag = 'a';
|
|
153
|
-
button.template.eventListeners = {};
|
|
154
|
-
return button;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module link/ui/linkactionsview
|
|
7
|
+
*/
|
|
8
|
+
import { ButtonView, View, ViewCollection, FocusCycler } from 'ckeditor5/src/ui';
|
|
9
|
+
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils';
|
|
10
|
+
import { icons } from 'ckeditor5/src/core';
|
|
11
|
+
import { ensureSafeUrl } from '../utils';
|
|
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) {
|
|
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.previewButtonView = this._createPreviewButton();
|
|
41
|
+
this.unlinkButtonView = this._createButton(t('Unlink'), unlinkIcon, 'unlink');
|
|
42
|
+
this.editButtonView = this._createButton(t('Edit link'), icons.pencil, 'edit');
|
|
43
|
+
this.set('href', undefined);
|
|
44
|
+
this._focusCycler = new FocusCycler({
|
|
45
|
+
focusables: this._focusables,
|
|
46
|
+
focusTracker: this.focusTracker,
|
|
47
|
+
keystrokeHandler: this.keystrokes,
|
|
48
|
+
actions: {
|
|
49
|
+
// Navigate fields backwards using the Shift + Tab keystroke.
|
|
50
|
+
focusPrevious: 'shift + tab',
|
|
51
|
+
// Navigate fields forwards using the Tab key.
|
|
52
|
+
focusNext: 'tab'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
this.setTemplate({
|
|
56
|
+
tag: 'div',
|
|
57
|
+
attributes: {
|
|
58
|
+
class: [
|
|
59
|
+
'ck',
|
|
60
|
+
'ck-link-actions',
|
|
61
|
+
'ck-responsive-form'
|
|
62
|
+
],
|
|
63
|
+
// https://github.com/ckeditor/ckeditor5-link/issues/90
|
|
64
|
+
tabindex: '-1'
|
|
65
|
+
},
|
|
66
|
+
children: [
|
|
67
|
+
this.previewButtonView,
|
|
68
|
+
this.editButtonView,
|
|
69
|
+
this.unlinkButtonView
|
|
70
|
+
]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @inheritDoc
|
|
75
|
+
*/
|
|
76
|
+
render() {
|
|
77
|
+
super.render();
|
|
78
|
+
const childViews = [
|
|
79
|
+
this.previewButtonView,
|
|
80
|
+
this.editButtonView,
|
|
81
|
+
this.unlinkButtonView
|
|
82
|
+
];
|
|
83
|
+
childViews.forEach(v => {
|
|
84
|
+
// Register the view as focusable.
|
|
85
|
+
this._focusables.add(v);
|
|
86
|
+
// Register the view in the focus tracker.
|
|
87
|
+
this.focusTracker.add(v.element);
|
|
88
|
+
});
|
|
89
|
+
// Start listening for the keystrokes coming from #element.
|
|
90
|
+
this.keystrokes.listenTo(this.element);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @inheritDoc
|
|
94
|
+
*/
|
|
95
|
+
destroy() {
|
|
96
|
+
super.destroy();
|
|
97
|
+
this.focusTracker.destroy();
|
|
98
|
+
this.keystrokes.destroy();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Focuses the fist {@link #_focusables} in the actions.
|
|
102
|
+
*/
|
|
103
|
+
focus() {
|
|
104
|
+
this._focusCycler.focusFirst();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Creates a button view.
|
|
108
|
+
*
|
|
109
|
+
* @param label The button label.
|
|
110
|
+
* @param icon The button icon.
|
|
111
|
+
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
|
112
|
+
* @returns The button view instance.
|
|
113
|
+
*/
|
|
114
|
+
_createButton(label, icon, eventName) {
|
|
115
|
+
const button = new ButtonView(this.locale);
|
|
116
|
+
button.set({
|
|
117
|
+
label,
|
|
118
|
+
icon,
|
|
119
|
+
tooltip: true
|
|
120
|
+
});
|
|
121
|
+
button.delegate('execute').to(this, eventName);
|
|
122
|
+
return button;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates a link href preview button.
|
|
126
|
+
*
|
|
127
|
+
* @returns The button view instance.
|
|
128
|
+
*/
|
|
129
|
+
_createPreviewButton() {
|
|
130
|
+
const button = new ButtonView(this.locale);
|
|
131
|
+
const bind = this.bindTemplate;
|
|
132
|
+
const t = this.t;
|
|
133
|
+
button.set({
|
|
134
|
+
withText: true,
|
|
135
|
+
tooltip: t('Open link in new tab')
|
|
136
|
+
});
|
|
137
|
+
button.extendTemplate({
|
|
138
|
+
attributes: {
|
|
139
|
+
class: [
|
|
140
|
+
'ck',
|
|
141
|
+
'ck-link-actions__preview'
|
|
142
|
+
],
|
|
143
|
+
href: bind.to('href', href => href && ensureSafeUrl(href)),
|
|
144
|
+
target: '_blank',
|
|
145
|
+
rel: 'noopener noreferrer'
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
button.bind('label').to(this, 'href', href => {
|
|
149
|
+
return href || t('This link has no URL');
|
|
150
|
+
});
|
|
151
|
+
button.bind('isEnabled').to(this, 'href', href => !!href);
|
|
152
|
+
button.template.tag = 'a';
|
|
153
|
+
button.template.eventListeners = {};
|
|
154
|
+
return button;
|
|
155
|
+
}
|
|
156
|
+
}
|