@ckeditor/ckeditor5-link 47.6.1-alpha.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.
Files changed (203) hide show
  1. package/LICENSE.md +1 -1
  2. package/ckeditor5-metadata.json +6 -6
  3. package/{src → dist}/autolink.d.ts +2 -2
  4. package/dist/index-editor.css +181 -105
  5. package/dist/index.css +169 -151
  6. package/dist/index.css.map +1 -1
  7. package/{src → dist}/index.d.ts +1 -1
  8. package/dist/index.js +8 -8
  9. package/dist/index.js.map +1 -1
  10. package/{src → dist}/link.d.ts +1 -1
  11. package/{src → dist}/linkcommand.d.ts +2 -2
  12. package/{src → dist}/linkconfig.d.ts +1 -1
  13. package/{src → dist}/linkediting.d.ts +3 -3
  14. package/{src → dist}/linkimage.d.ts +1 -1
  15. package/{src → dist}/linkimageediting.d.ts +3 -2
  16. package/{src → dist}/linkimageui.d.ts +3 -2
  17. package/{src → dist}/linkui.d.ts +2 -2
  18. package/{src → dist}/ui/linkbuttonview.d.ts +2 -2
  19. package/{src → dist}/ui/linkformview.d.ts +2 -4
  20. package/{src → dist}/ui/linkpreviewbuttonview.d.ts +2 -2
  21. package/{src → dist}/ui/linkpropertiesview.d.ts +2 -2
  22. package/{src → dist}/ui/linkprovideritemsview.d.ts +2 -2
  23. package/{src → dist}/unlinkcommand.d.ts +1 -1
  24. package/{src → dist}/utils/automaticdecorators.d.ts +2 -2
  25. package/{src → dist}/utils/manualdecorator.d.ts +4 -4
  26. package/{src → dist}/utils.d.ts +2 -2
  27. package/package.json +29 -52
  28. package/build/link.js +0 -5
  29. package/build/translations/af.js +0 -1
  30. package/build/translations/ar.js +0 -1
  31. package/build/translations/ast.js +0 -1
  32. package/build/translations/az.js +0 -1
  33. package/build/translations/be.js +0 -1
  34. package/build/translations/bg.js +0 -1
  35. package/build/translations/bn.js +0 -1
  36. package/build/translations/bs.js +0 -1
  37. package/build/translations/ca.js +0 -1
  38. package/build/translations/cs.js +0 -1
  39. package/build/translations/da.js +0 -1
  40. package/build/translations/de-ch.js +0 -1
  41. package/build/translations/de.js +0 -1
  42. package/build/translations/el.js +0 -1
  43. package/build/translations/en-au.js +0 -1
  44. package/build/translations/en-gb.js +0 -1
  45. package/build/translations/eo.js +0 -1
  46. package/build/translations/es-co.js +0 -1
  47. package/build/translations/es.js +0 -1
  48. package/build/translations/et.js +0 -1
  49. package/build/translations/eu.js +0 -1
  50. package/build/translations/fa.js +0 -1
  51. package/build/translations/fi.js +0 -1
  52. package/build/translations/fr.js +0 -1
  53. package/build/translations/gl.js +0 -1
  54. package/build/translations/gu.js +0 -1
  55. package/build/translations/he.js +0 -1
  56. package/build/translations/hi.js +0 -1
  57. package/build/translations/hr.js +0 -1
  58. package/build/translations/hu.js +0 -1
  59. package/build/translations/hy.js +0 -1
  60. package/build/translations/id.js +0 -1
  61. package/build/translations/it.js +0 -1
  62. package/build/translations/ja.js +0 -1
  63. package/build/translations/jv.js +0 -1
  64. package/build/translations/kk.js +0 -1
  65. package/build/translations/km.js +0 -1
  66. package/build/translations/kn.js +0 -1
  67. package/build/translations/ko.js +0 -1
  68. package/build/translations/ku.js +0 -1
  69. package/build/translations/lt.js +0 -1
  70. package/build/translations/lv.js +0 -1
  71. package/build/translations/ms.js +0 -1
  72. package/build/translations/nb.js +0 -1
  73. package/build/translations/ne.js +0 -1
  74. package/build/translations/nl.js +0 -1
  75. package/build/translations/no.js +0 -1
  76. package/build/translations/oc.js +0 -1
  77. package/build/translations/pl.js +0 -1
  78. package/build/translations/pt-br.js +0 -1
  79. package/build/translations/pt.js +0 -1
  80. package/build/translations/ro.js +0 -1
  81. package/build/translations/ru.js +0 -1
  82. package/build/translations/si.js +0 -1
  83. package/build/translations/sk.js +0 -1
  84. package/build/translations/sl.js +0 -1
  85. package/build/translations/sq.js +0 -1
  86. package/build/translations/sr-latn.js +0 -1
  87. package/build/translations/sr.js +0 -1
  88. package/build/translations/sv.js +0 -1
  89. package/build/translations/th.js +0 -1
  90. package/build/translations/ti.js +0 -1
  91. package/build/translations/tk.js +0 -1
  92. package/build/translations/tr.js +0 -1
  93. package/build/translations/tt.js +0 -1
  94. package/build/translations/ug.js +0 -1
  95. package/build/translations/uk.js +0 -1
  96. package/build/translations/ur.js +0 -1
  97. package/build/translations/uz.js +0 -1
  98. package/build/translations/vi.js +0 -1
  99. package/build/translations/zh-cn.js +0 -1
  100. package/build/translations/zh.js +0 -1
  101. package/lang/contexts.json +0 -16
  102. package/lang/translations/af.po +0 -68
  103. package/lang/translations/ar.po +0 -68
  104. package/lang/translations/ast.po +0 -68
  105. package/lang/translations/az.po +0 -68
  106. package/lang/translations/be.po +0 -68
  107. package/lang/translations/bg.po +0 -68
  108. package/lang/translations/bn.po +0 -70
  109. package/lang/translations/bs.po +0 -68
  110. package/lang/translations/ca.po +0 -68
  111. package/lang/translations/cs.po +0 -68
  112. package/lang/translations/da.po +0 -68
  113. package/lang/translations/de-ch.po +0 -68
  114. package/lang/translations/de.po +0 -68
  115. package/lang/translations/el.po +0 -68
  116. package/lang/translations/en-au.po +0 -68
  117. package/lang/translations/en-gb.po +0 -68
  118. package/lang/translations/en.po +0 -68
  119. package/lang/translations/eo.po +0 -68
  120. package/lang/translations/es-co.po +0 -68
  121. package/lang/translations/es.po +0 -68
  122. package/lang/translations/et.po +0 -68
  123. package/lang/translations/eu.po +0 -68
  124. package/lang/translations/fa.po +0 -68
  125. package/lang/translations/fi.po +0 -68
  126. package/lang/translations/fr.po +0 -68
  127. package/lang/translations/gl.po +0 -68
  128. package/lang/translations/gu.po +0 -68
  129. package/lang/translations/he.po +0 -68
  130. package/lang/translations/hi.po +0 -68
  131. package/lang/translations/hr.po +0 -68
  132. package/lang/translations/hu.po +0 -68
  133. package/lang/translations/hy.po +0 -68
  134. package/lang/translations/id.po +0 -68
  135. package/lang/translations/it.po +0 -68
  136. package/lang/translations/ja.po +0 -68
  137. package/lang/translations/jv.po +0 -68
  138. package/lang/translations/kk.po +0 -68
  139. package/lang/translations/km.po +0 -68
  140. package/lang/translations/kn.po +0 -68
  141. package/lang/translations/ko.po +0 -68
  142. package/lang/translations/ku.po +0 -68
  143. package/lang/translations/lt.po +0 -68
  144. package/lang/translations/lv.po +0 -68
  145. package/lang/translations/ms.po +0 -68
  146. package/lang/translations/nb.po +0 -68
  147. package/lang/translations/ne.po +0 -68
  148. package/lang/translations/nl.po +0 -68
  149. package/lang/translations/no.po +0 -68
  150. package/lang/translations/oc.po +0 -68
  151. package/lang/translations/pl.po +0 -68
  152. package/lang/translations/pt-br.po +0 -68
  153. package/lang/translations/pt.po +0 -68
  154. package/lang/translations/ro.po +0 -68
  155. package/lang/translations/ru.po +0 -68
  156. package/lang/translations/si.po +0 -68
  157. package/lang/translations/sk.po +0 -68
  158. package/lang/translations/sl.po +0 -68
  159. package/lang/translations/sq.po +0 -68
  160. package/lang/translations/sr-latn.po +0 -68
  161. package/lang/translations/sr.po +0 -68
  162. package/lang/translations/sv.po +0 -68
  163. package/lang/translations/th.po +0 -68
  164. package/lang/translations/ti.po +0 -68
  165. package/lang/translations/tk.po +0 -68
  166. package/lang/translations/tr.po +0 -68
  167. package/lang/translations/tt.po +0 -68
  168. package/lang/translations/ug.po +0 -68
  169. package/lang/translations/uk.po +0 -68
  170. package/lang/translations/ur.po +0 -68
  171. package/lang/translations/uz.po +0 -68
  172. package/lang/translations/vi.po +0 -68
  173. package/lang/translations/zh-cn.po +0 -68
  174. package/lang/translations/zh.po +0 -68
  175. package/src/augmentation.js +0 -5
  176. package/src/autolink.js +0 -307
  177. package/src/index.js +0 -25
  178. package/src/link.js +0 -37
  179. package/src/linkcommand.js +0 -431
  180. package/src/linkconfig.js +0 -5
  181. package/src/linkediting.js +0 -402
  182. package/src/linkimage.js +0 -37
  183. package/src/linkimageediting.js +0 -264
  184. package/src/linkimageui.js +0 -102
  185. package/src/linkui.js +0 -1072
  186. package/src/ui/linkbuttonview.js +0 -54
  187. package/src/ui/linkformview.js +0 -302
  188. package/src/ui/linkpreviewbuttonview.js +0 -43
  189. package/src/ui/linkpropertiesview.js +0 -170
  190. package/src/ui/linkprovideritemsview.js +0 -207
  191. package/src/unlinkcommand.js +0 -66
  192. package/src/utils/automaticdecorators.js +0 -181
  193. package/src/utils/conflictingdecorators.js +0 -80
  194. package/src/utils/manualdecorator.js +0 -69
  195. package/src/utils.js +0 -157
  196. package/theme/link.css +0 -10
  197. package/theme/linkform.css +0 -24
  198. package/theme/linkimage.css +0 -16
  199. package/theme/linkproperties.css +0 -4
  200. package/theme/linkprovideritems.css +0 -18
  201. package/theme/linktoolbar.css +0 -12
  202. /package/{src → dist}/augmentation.d.ts +0 -0
  203. /package/{src → dist}/utils/conflictingdecorators.d.ts +0 -0
@@ -1,54 +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
- /**
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 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
- }
@@ -1,302 +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
- /**
6
- * @module link/ui/linkformview
7
- */
8
- import { ButtonView, ListView, ListItemView, FocusCycler, LabeledFieldView, FormHeaderView, FormRowView, View, ViewCollection, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';
9
- import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
- import { IconPreviousArrow } from 'ckeditor5/src/icons.js';
11
- // See: #8833.
12
- // eslint-disable-next-line ckeditor5-rules/ckeditor-imports
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';
16
- import '../../theme/linkform.css';
17
- /**
18
- * The link form view.
19
- */
20
- export 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;
65
- /**
66
- * Creates an instance of the {@link module:link/ui/linkformview~LinkFormView} class.
67
- *
68
- * Also see {@link #render}.
69
- *
70
- * @param locale The localization services instance.
71
- * @param validators Form validators used by {@link #isValid}.
72
- */
73
- constructor(locale, validators) {
74
- super(locale);
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();
81
- this.urlInputView = this._createUrlInput();
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
- });
93
- this._focusCycler = new FocusCycler({
94
- focusables: this._focusables,
95
- focusTracker: this.focusTracker,
96
- keystrokeHandler: this.keystrokes,
97
- actions: {
98
- // Navigate form fields backwards using the Shift + Tab keystroke.
99
- focusPrevious: 'shift + tab',
100
- // Navigate form fields forwards using the Tab key.
101
- focusNext: 'tab'
102
- }
103
- });
104
- this.setTemplate({
105
- tag: 'form',
106
- attributes: {
107
- class: [
108
- 'ck',
109
- 'ck-form',
110
- 'ck-link-form',
111
- 'ck-responsive-form'
112
- ],
113
- // https://github.com/ckeditor/ckeditor5-link/issues/90
114
- tabindex: '-1'
115
- },
116
- children: this.children
117
- });
118
- }
119
- /**
120
- * @inheritDoc
121
- */
122
- render() {
123
- super.render();
124
- submitHandler({
125
- view: this
126
- });
127
- const childViews = [
128
- this.urlInputView,
129
- this.saveButtonView,
130
- ...this.providersListChildren,
131
- this.backButtonView,
132
- this.displayedTextInputView
133
- ];
134
- childViews.forEach(v => {
135
- // Register the view as focusable.
136
- this._focusables.add(v);
137
- // Register the view in the focus tracker.
138
- this.focusTracker.add(v.element);
139
- });
140
- // Start listening for the keystrokes coming from #element.
141
- this.keystrokes.listenTo(this.element);
142
- }
143
- /**
144
- * @inheritDoc
145
- */
146
- destroy() {
147
- super.destroy();
148
- this.focusTracker.destroy();
149
- this.keystrokes.destroy();
150
- }
151
- /**
152
- * Focuses the fist {@link #_focusables} in the form.
153
- */
154
- focus() {
155
- this._focusCycler.focusFirst();
156
- }
157
- /**
158
- * Validates the form and returns `false` when some fields are invalid.
159
- */
160
- isValid() {
161
- this.resetFormStatus();
162
- for (const validator of this._validators) {
163
- const errorText = validator(this);
164
- // One error per field is enough.
165
- if (errorText) {
166
- // Apply updated error.
167
- this.urlInputView.errorText = errorText;
168
- return false;
169
- }
170
- }
171
- return true;
172
- }
173
- /**
174
- * Cleans up the supplementary error and information text of the {@link #urlInputView}
175
- * bringing them back to the state when the form has been displayed for the first time.
176
- *
177
- * See {@link #isValid}.
178
- */
179
- resetFormStatus() {
180
- this.urlInputView.errorText = null;
181
- }
182
- /**
183
- * Creates a back button view that cancels the form.
184
- */
185
- _createBackButton() {
186
- const t = this.locale.t;
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;
196
- }
197
- /**
198
- * Creates a save button view that inserts the link.
199
- */
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'
209
- });
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({
229
- attributes: {
230
- class: [
231
- 'ck-link-form__providers-list'
232
- ]
233
- }
234
- });
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;
241
- }
242
- /**
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.
254
- *
255
- * @returns Labeled field view instance.
256
- */
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;
264
- }
265
- /**
266
- * Populates the {@link #children} collection of the form.
267
- */
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
- }));
288
- }
289
- /**
290
- * The native DOM `value` of the {@link #urlInputView} element.
291
- *
292
- * **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
293
- * which works one way only and may not represent the actual state of the component in the DOM.
294
- */
295
- get url() {
296
- const { element } = this.urlInputView.fieldView;
297
- if (!element) {
298
- return null;
299
- }
300
- return element.value.trim();
301
- }
302
- }
@@ -1,43 +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
- /**
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 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
- }
@@ -1,170 +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
- /**
6
- * @module link/ui/linkpropertiesview
7
- */
8
- import { ButtonView, FocusCycler, FormHeaderView, View, ViewCollection, ListView, ListItemView } from 'ckeditor5/src/ui.js';
9
- import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
10
- import { IconPreviousArrow } from '@ckeditor/ckeditor5-icons';
11
- import '../../theme/linkproperties.css';
12
- /**
13
- * The link properties view controller class.
14
- *
15
- * See {@link module:link/ui/linkpropertiesview~LinkPropertiesView}.
16
- */
17
- export class LinkPropertiesView extends View {
18
- /**
19
- * Tracks information about DOM focus in the form.
20
- */
21
- focusTracker = new FocusTracker();
22
- /**
23
- * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
24
- */
25
- keystrokes = new KeystrokeHandler();
26
- /**
27
- * The Back button view displayed in the header.
28
- */
29
- backButtonView;
30
- /**
31
- * A collection of child views.
32
- */
33
- children;
34
- /**
35
- * A collection of {@link module:ui/button/switchbuttonview~SwitchButtonView},
36
- * which corresponds to {@link module:link/linkcommand~LinkCommand#manualDecorators manual decorators}
37
- * configured in the editor.
38
- */
39
- listChildren;
40
- /**
41
- * A collection of views that can be focused in the form.
42
- */
43
- _focusables = new ViewCollection();
44
- /**
45
- * Helps cycling over {@link #_focusables} in the form.
46
- */
47
- _focusCycler;
48
- /**
49
- * Creates an instance of the {@link module:link/ui/linkpropertiesview~LinkPropertiesView} class.
50
- *
51
- * Also see {@link #render}.
52
- *
53
- * @param locale The localization services instance.
54
- */
55
- constructor(locale) {
56
- super(locale);
57
- this.backButtonView = this._createBackButton();
58
- this.listChildren = this.createCollection();
59
- this.children = this.createCollection([
60
- this._createHeaderView(),
61
- this._createListView()
62
- ]);
63
- this._focusCycler = new FocusCycler({
64
- focusables: this._focusables,
65
- focusTracker: this.focusTracker,
66
- keystrokeHandler: this.keystrokes,
67
- actions: {
68
- // Navigate form fields backwards using the Shift + Tab keystroke.
69
- focusPrevious: 'shift + tab',
70
- // Navigate form fields forwards using the Tab key.
71
- focusNext: 'tab'
72
- }
73
- });
74
- this.setTemplate({
75
- tag: 'div',
76
- attributes: {
77
- class: [
78
- 'ck',
79
- 'ck-link-properties'
80
- ],
81
- // https://github.com/ckeditor/ckeditor5-link/issues/90
82
- tabindex: '-1'
83
- },
84
- children: this.children
85
- });
86
- // Close the panel on esc key press when the **form has focus**.
87
- this.keystrokes.set('Esc', (data, cancel) => {
88
- this.fire('back');
89
- cancel();
90
- });
91
- }
92
- /**
93
- * @inheritDoc
94
- */
95
- render() {
96
- super.render();
97
- const childViews = [
98
- ...this.listChildren,
99
- this.backButtonView
100
- ];
101
- childViews.forEach(v => {
102
- // Register the view as focusable.
103
- this._focusables.add(v);
104
- // Register the view in the focus tracker.
105
- this.focusTracker.add(v.element);
106
- });
107
- // Start listening for the keystrokes coming from #element.
108
- this.keystrokes.listenTo(this.element);
109
- }
110
- /**
111
- * @inheritDoc
112
- */
113
- destroy() {
114
- super.destroy();
115
- this.focusTracker.destroy();
116
- this.keystrokes.destroy();
117
- }
118
- /**
119
- * Focuses the fist {@link #_focusables} in the form.
120
- */
121
- focus() {
122
- this._focusCycler.focusFirst();
123
- }
124
- /**
125
- * Creates a back button view.
126
- */
127
- _createBackButton() {
128
- const t = this.locale.t;
129
- const backButton = new ButtonView(this.locale);
130
- // TODO: maybe we should have a dedicated BackButtonView in the UI library.
131
- backButton.set({
132
- class: 'ck-button-back',
133
- label: t('Back'),
134
- icon: IconPreviousArrow,
135
- tooltip: true
136
- });
137
- backButton.delegate('execute').to(this, 'back');
138
- return backButton;
139
- }
140
- /**
141
- * Creates a header view for the form.
142
- */
143
- _createHeaderView() {
144
- const t = this.locale.t;
145
- const header = new FormHeaderView(this.locale, {
146
- label: t('Link properties')
147
- });
148
- header.children.add(this.backButtonView, 0);
149
- return header;
150
- }
151
- /**
152
- * Creates a form view that displays the {@link #listChildren} collection.
153
- */
154
- _createListView() {
155
- const listView = new ListView(this.locale);
156
- listView.extendTemplate({
157
- attributes: {
158
- class: [
159
- 'ck-link__list'
160
- ]
161
- }
162
- });
163
- listView.items.bindTo(this.listChildren).using(item => {
164
- const listItemView = new ListItemView(this.locale);
165
- listItemView.children.add(item);
166
- return listItemView;
167
- });
168
- return listView;
169
- }
170
- }